Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 120 additions & 118 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,34 @@ add_library(project_warnings INTERFACE)

message(STATUS ${CMAKE_SYSTEM_NAME})

if(WASM)
message(STATUS "Compiling for webassembly using emscripten")
target_compile_definitions(project_options INTERFACE "-DWASM")
target_compile_options(project_options INTERFACE "-fexceptions")
endif()
if (WASM)
message(STATUS "Compiling for webassembly using emscripten")
target_compile_definitions(project_options INTERFACE "-DWASM")
target_compile_options(project_options INTERFACE "-fexceptions")
endif ()

if(CMAKE_HOST_WIN32)
message("Compiling with CMAKE_HOST_WIN32")
if (CMAKE_HOST_WIN32)
message("Compiling with CMAKE_HOST_WIN32")

# bigobj is required for windows builds
target_compile_options(project_options INTERFACE "/bigobj")
set_target_properties(project_options PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
# bigobj is required for windows builds
target_compile_options(project_options INTERFACE "/bigobj")
set_target_properties(project_options PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()

target_compile_features(project_options INTERFACE ${PROJ_CXX_STD_FEATURE})

if(ENABLE_PCH)
target_precompile_headers(project_options
INTERFACE
<vector>
<string>
<map>
<utility>
<memory>
<array>
<optional>
)
endif()
if (ENABLE_PCH)
target_precompile_headers(project_options
INTERFACE
<vector>
<string>
<map>
<utility>
<memory>
<array>
<optional>
)
endif ()

# import utility methods for cmake
include(${CMAKE_CONFIG_FOLDER}/settings/Utilities.cmake)
Expand All @@ -119,6 +119,8 @@ enable_sanitizers(project_options)
# allow for static analysis
include(${CMAKE_CONFIG_FOLDER}/settings/StaticAnalyzers.cmake)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

# glm
find_package(glm REQUIRED)

Expand All @@ -131,107 +133,107 @@ find_package(spdlog REQUIRED)
# boost
find_package(Boost COMPONENTS Random REQUIRED)

if(NOT WASM)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

# find the dependencies from conan
set(PYBIND11_FINDPYTHON FALSE)
if (ENABLE_TESTING OR NOT WASM)
# stb
find_package(stb REQUIRED)
endif ()

# set(Python_ROOT_DIR /opt/python/$ENV{PYBIN})
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
# pybind11
find_package(pybind11 REQUIRED)

# GTest
if(ENABLE_TESTING)
# GTest
if (ENABLE_TESTING)
# gtest
find_package(GTest REQUIRED)
endif()
endif ()

if (NOT WASM)
# find the dependencies from conan
set(PYBIND11_FINDPYTHON FALSE)

# stb
find_package(stb REQUIRED)
# set(Python_ROOT_DIR /opt/python/$ENV{PYBIN})
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
# pybind11
find_package(pybind11 REQUIRED)

# Vulkan
find_package(volk REQUIRED)
# Vulkan
find_package(volk REQUIRED)

# ShaderC for compiling shaders
find_package(shaderc REQUIRED)
# ShaderC for compiling shaders
find_package(shaderc REQUIRED)

endif()
endif ()

include(${CMAKE_CONFIG_FOLDER}/targets/griddly.cmake)

if(WASM)
include(${CMAKE_CONFIG_FOLDER}/targets/wasm.cmake)
else()
# Compile shaders and copy them into resources directory in build output
if(NOT WASM)
message(STATUS "Compiling shaders...")

set(ENV{GLSLC_BIN} ${CONAN_SHADERC_ROOT}/bin/glslc)

if(CMAKE_HOST_WIN32)
execute_process(COMMAND powershell ${CMAKE_CURRENT_SOURCE_DIR}/compile_shaders.bat RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
message( FATAL_ERROR "Cannot compile shaders: ${STATUS}")
endif()
else()
execute_process(COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/compile_shaders.sh RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
message( FATAL_ERROR "Cannot compile shaders: ${STATUS}")
endif()
endif()

if(ENABLE_PYTHON_BINDINGS)
message("Configuring Python Bindings.")
include(${CMAKE_CONFIG_FOLDER}/targets/python_griddly.cmake)
endif()

if(ENABLE_TESTING)
message("Configuring Tests.")
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) # prevent CTest from flooding the target space with CI/CD targets
include(CTest)
enable_testing()
include(${CMAKE_CONFIG_FOLDER}/targets/test.cmake)
endif()
endif()

include(CMakePackageConfigHelpers)

# Want the python lib to be output in the same directory as the other dll/so
if(CMAKE_HOST_WIN32)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set_target_properties(${PYTHON_MODULE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BIN_OUTPUT_DIR})
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
endif()

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(TARGETS project_options EXPORT ${PROJECT_NAME_LOWERCASE}Options)
install(TARGETS ${GRIDDLY_LIB_NAME}_interface ${GRIDDLY_LIB_NAME}_shared ${GRIDDLY_LIB_NAME}_static
EXPORT ${PROJECT_NAME_LOWERCASE}Targets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)

include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME_LOWERCASE}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}Config.cmake"
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE}
)
install(EXPORT ${PROJECT_NAME_LOWERCASE}Options DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(EXPORT ${PROJECT_NAME_LOWERCASE}Targets DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}ConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}Config.cmake"
DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(FILES ${GRIDDLY_HEADERS} DESTINATION include)
install(DIRECTORY ${GRIDDLY_RESOURCE_DIR} DESTINATION resources)
endif()
if (ENABLE_TESTING)
message("Configuring Tests.")
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) # prevent CTest from flooding the target space with CI/CD targets
include(CTest)
enable_testing()
include(${CMAKE_CONFIG_FOLDER}/targets/test.cmake)
endif ()

if (WASM)
include(${CMAKE_CONFIG_FOLDER}/targets/wasm.cmake)
else ()
# Compile shaders and copy them into resources directory in build output
if (NOT WASM)
message(STATUS "Compiling shaders...")

set(ENV{GLSLC_BIN} ${CONAN_SHADERC_ROOT}/bin/glslc)

if (CMAKE_HOST_WIN32)
execute_process(COMMAND powershell ${CMAKE_CURRENT_SOURCE_DIR}/compile_shaders.bat RESULT_VARIABLE STATUS)
if (STATUS AND NOT STATUS EQUAL 0)
message(FATAL_ERROR "Cannot compile shaders: ${STATUS}")
endif ()
else ()
execute_process(COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/compile_shaders.sh RESULT_VARIABLE STATUS)
if (STATUS AND NOT STATUS EQUAL 0)
message(FATAL_ERROR "Cannot compile shaders: ${STATUS}")
endif ()
endif ()

if (ENABLE_PYTHON_BINDINGS)
message("Configuring Python Bindings.")
include(${CMAKE_CONFIG_FOLDER}/targets/python_griddly.cmake)
endif ()
endif ()

include(CMakePackageConfigHelpers)

# Want the python lib to be output in the same directory as the other dll/so
if (CMAKE_HOST_WIN32)
foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set_target_properties(${PYTHON_MODULE} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${BIN_OUTPUT_DIR})
endforeach (OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
endif ()

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(TARGETS project_options EXPORT ${PROJECT_NAME_LOWERCASE}Options)
install(TARGETS ${GRIDDLY_LIB_NAME}_interface ${GRIDDLY_LIB_NAME}_shared ${GRIDDLY_LIB_NAME}_static
EXPORT ${PROJECT_NAME_LOWERCASE}Targets
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)

include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME_LOWERCASE}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}Config.cmake"
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE}
)
install(EXPORT ${PROJECT_NAME_LOWERCASE}Options DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(EXPORT ${PROJECT_NAME_LOWERCASE}Targets DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}ConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME_LOWERCASE}Config.cmake"
DESTINATION lib/cmake/${PROJECT_NAME_LOWERCASE})
install(FILES ${GRIDDLY_HEADERS} DESTINATION include)
install(DIRECTORY ${GRIDDLY_RESOURCE_DIR} DESTINATION resources)
endif ()
8 changes: 8 additions & 0 deletions cmake/targets/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

file(GLOB_RECURSE TEST_SOURCES "${GRIDDLY_TEST_SRC_DIR}/*.cpp")

list(
REMOVE_ITEM
TEST_SOURCES
${GRIDDLY_TEST_SRC_DIR}/Griddly/Core/Observers/SpriteObserverTest.cpp
${GRIDDLY_TEST_SRC_DIR}/Griddly/Core/Observers/IsometricSpriteObserverTest.cpp
${GRIDDLY_TEST_SRC_DIR}/Griddly/Core/Observers/BlockObserverTest.cpp
)

add_executable(
${GRIDDLY_TEST_BIN_NAME}
${TEST_SOURCES}
Expand Down
3 changes: 3 additions & 0 deletions deps/wasm/conanfile_wasm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ glm/0.9.9.8
yaml-cpp/0.6.3
spdlog/1.9.2
boost/1.82.0
gtest/1.11.0
stb/20200203

[generators]
CMakeToolchain
CMakeDeps
cmake_paths

[options]
boost:shared=False
Expand Down
Loading