Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

Commit

Permalink
Merge pull request #89 from Milerius/dev
Browse files Browse the repository at this point in the history
update cmake installation
  • Loading branch information
Milerius authored Aug 2, 2018
2 parents 3622d84 + e006a72 commit b965a6e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project(shiva VERSION 0.2)
enable_testing()

##! Project options
option(SHIVA_BUILD_TESTS "Build tests of shiva C++ engine" ON)
option(SHIVA_BUILD_TESTS "Build tests of shiva C++ engine" OFF)
option(SHIVA_BUILD_EXAMPLES "Build examples of shiva C++ engine" OFF)
option(SHIVA_USE_SFML_AS_RENDERER "Build shiva with SFML rendering" OFF)
option(DISABLE_INSTALL_SHIVA_CORE "Disable install main targets" OFF)
Expand Down
18 changes: 17 additions & 1 deletion cmake/module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,25 @@ macro(CREATE_MODULE ModuleAlias LibSources BuildInterfaceDirectory)
if (USE_PROJECT_IN_AN_IDE)
target_sources(${RealModuleName} INTERFACE ${LibSources})
endif ()

set(ExtraMacroArgs ${ARGN})

set(INSTALL_MODULE_NAME_DIRECTORY "${RealModuleName}")
# Get the length of the list
list(LENGTH ExtraMacroArgs NumExtraMacroArgs)

# Execute the following block only if the length is > 0
if(NumExtraMacroArgs GREATER 0)
message(STATUS ">>> First optional arg = \"${ARGV2}\"")
foreach(ExtraArg ${ExtraMacroArgs})
message(STATUS ">>> Element of list of opt args = ${ExtraArg}")
set(INSTALL_MODULE_NAME_DIRECTORY "${ExtraArg}")
endforeach()
endif()

target_include_directories(${RealModuleName} INTERFACE
$<BUILD_INTERFACE:${BuildInterfaceDirectory}>
$<INSTALL_INTERFACE:include/shiva/modules/${RealModuleName}>)
$<INSTALL_INTERFACE:include/shiva/modules/${INSTALL_MODULE_NAME_DIRECTORY}>)
add_library(${ModuleAlias} ALIAS ${RealModuleName})
MSG_CYAN_BOLD(STATUS "Module" "${ModuleAlias}" "successfully created.")
endmacro()
Expand Down
34 changes: 19 additions & 15 deletions cmake/shiva-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,60 @@

MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})

include("${CMAKE_CURRENT_LIST_DIR}/shiva-range-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-timer-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-pp-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-enums-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-meta-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-reflection-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-input-targets.cmake")

find_package(Threads REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-shiva-spdlog-targets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/shiva-entt-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-event-targets.cmake")

find_package(Boost COMPONENTS filesystem system REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-stacktrace-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-filesystem-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-dll-targets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/shiva-error-targets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/shiva-range-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-event-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-ecs-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-input-targets.cmake")


find_package(sol2 CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-lua-targets.cmake")

find_package(pybind11 CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-pyscripting-targets.cmake")

find_package(Threads REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-shiva-spdlog-targets.cmake")

include("${CMAKE_CURRENT_LIST_DIR}/shiva-world-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-targets.cmake")

##! O Dependancies
check_required_components("range")
check_required_components("timer")
check_required_components("pp")
check_required_components("enums")
check_required_components("meta")
check_required_components("reflection")

##! 1 Dependancies

# input dependancies: enums
check_required_components("input")
check_required_components("shiva-spdlog")
check_required_components("entt")
check_required_components("stacktrace")
check_required_components("filesystem")
check_required_components("dll")
check_required_components("entt")
check_required_components("event")
check_required_components("error")
check_required_components("range")
check_required_components("event")
check_required_components("ecs")
check_required_components("input")
check_required_components("lua")
check_required_components("pyscripting")
check_required_components("spdlog")
check_required_components("world")
check_required_components("shiva")
28 changes: 22 additions & 6 deletions cmake/shiva-sfml-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,40 @@

MESSAGE(STATUS ${CMAKE_CURRENT_LIST_DIR})
find_package(shiva CONFIG REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/shiva-system-sfml-graphics-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-shiva-system-sfml-resources-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-shiva-system-sfml-graphics-targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/shiva-shiva-system-sfml-inputs-targets.cmake")

macro(import_plugin plugin_name)
get_property(result TARGET ${plugin_name} PROPERTY IMPORTED_LOCATION_RELEASE)
if(CMAKE_BUILD_TYPE MATCHES Debug)
get_property(result TARGET ${plugin_name} PROPERTY IMPORTED_LOCATION_DEBUG)
else()
get_property(result TARGET ${plugin_name} PROPERTY IMPORTED_LOCATION_RELEASE)
endif()

file(COPY ${result}
DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
get_filename_component(result_filename ${result} NAME)

message(STATUS "plugin to copy -> ${result}")
message(STATUS "plugin filename to copy -> ${result_filename}")

configure_file(${result}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${result_filename}
COPYONLY)
endmacro()

##! directory output plugins
set(SAVE_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/systems)

import_plugin(shiva::system-sfml-graphics)
import_plugin(shiva::shiva-system-sfml-resources)
import_plugin(shiva::shiva-system-sfml-graphics)
import_plugin(shiva::shiva-system-sfml-inputs)

##! restore output plugins
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${SAVE_OUTPUT_DIRECTORY}")

##! check components
check_required_components("system-sfml-graphics")
check_required_components("shiva-system-sfml-resources")
check_required_components("shiva-system-sfml-graphics")
check_required_components("shiva-system-sfml-input")

2 changes: 1 addition & 1 deletion modules/event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include(CMakeSources.cmake)
set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

CREATE_MODULE(shiva::event "${MODULE_SOURCES}" ${MODULE_PATH})
target_link_libraries(event INTERFACE shiva::ecs shiva::input)
target_link_libraries(event INTERFACE shiva::input)
AUTO_TARGETS_MODULE_INSTALL(event)
2 changes: 1 addition & 1 deletion modules/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (WIN32)
file(COPY ${PYTHON_DLL} DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif ()

CREATE_MODULE(shiva::pyscripting "${MODULE_SOURCES}" ${MODULE_PATH})
CREATE_MODULE(shiva::pyscripting "${MODULE_SOURCES}" ${MODULE_PATH} "python")

target_link_libraries(pyscripting INTERFACE shiva::ecs shiva::input pybind11::embed pybind11::module)

Expand Down
4 changes: 2 additions & 2 deletions modules/sfml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#set(CMAKE_POSITION_INDEPENDENT_CODE OFF)

macro(mini_module module_name additional_library)
include(shiva/sfml/${module_name}/CMakeSources.cmake)
set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
CREATE_MODULE_PLUGIN(shiva::shiva-system-sfml-${module_name} "${MODULE_SOURCES}" ${MODULE_PATH} "systems" "sfml/shiva")
target_link_libraries(shiva-system-sfml-${module_name} PUBLIC shiva::ecs "${additional_library}")
AUTO_TARGETS_PLUGINS_INSTALL(system-sfml-${module_name} shiva-sfml)
AUTO_TARGETS_PLUGINS_INSTALL(shiva-system-sfml-${module_name} shiva-sfml)
endmacro()

if (SHIVA_USE_SFML_AS_RENDERER)

find_package(SFML CONFIG REQUIRED system window graphics audio)
mini_module(resources "sfml-graphics;sfml-audio;shiva::lua")
mini_module(graphics sfml-graphics)
Expand Down
2 changes: 1 addition & 1 deletion modules/spdlog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(Threads REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
CREATE_MODULE(shiva::shiva-spdlog "${MODULE_SOURCES}" ${MODULE_PATH})
CREATE_MODULE(shiva::shiva-spdlog "${MODULE_SOURCES}" ${MODULE_PATH} "spdlog")
target_link_libraries(shiva-spdlog INTERFACE spdlog::spdlog Threads::Threads fmt::fmt)
target_compile_options(shiva-spdlog INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/wd4244 /wd4127>)
AUTO_TARGETS_MODULE_INSTALL(shiva-spdlog)

0 comments on commit b965a6e

Please sign in to comment.