Files
Faset_Engine/cmake/Runtime.cmake
T

30 lines
1.8 KiB
CMake

add_library(faset_runtime STATIC
${CMAKE_CURRENT_LIST_DIR}/../src/runtime/Runtime.cpp
${CMAKE_CURRENT_LIST_DIR}/../src/runtime/Physics.cpp)
add_library(Faset::Runtime ALIAS faset_runtime)
target_compile_features(faset_runtime PUBLIC cxx_std_20)
target_include_directories(faset_runtime PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../include)
target_link_libraries(faset_runtime PUBLIC nlohmann_json::nlohmann_json PRIVATE EnTT::EnTT box2d box3d)
set(FASET_GAMEPLAY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/examples/gameplay" CACHE PATH "Directory containing the game's Gameplay.cpp and Gameplay.hpp")
if(NOT EXISTS "${FASET_GAMEPLAY_SOURCE_DIR}/Gameplay.cpp" OR NOT EXISTS "${FASET_GAMEPLAY_SOURCE_DIR}/Gameplay.hpp")
message(FATAL_ERROR "FASET_GAMEPLAY_SOURCE_DIR must contain Gameplay.cpp and Gameplay.hpp")
endif()
add_library(faset_gameplay STATIC "${FASET_GAMEPLAY_SOURCE_DIR}/Gameplay.cpp")
add_library(Faset::Gameplay ALIAS faset_gameplay)
target_include_directories(faset_gameplay PUBLIC "${FASET_GAMEPLAY_SOURCE_DIR}")
target_link_libraries(faset_gameplay PUBLIC faset_runtime)
if(BUILD_TESTING)
add_executable(faset_runtime_tests ${CMAKE_CURRENT_LIST_DIR}/../tests/runtime_tests.cpp)
if(FASET_GAMEPLAY_SOURCE_DIR STREQUAL "${PROJECT_SOURCE_DIR}/examples/gameplay")
target_link_libraries(faset_runtime_tests PRIVATE faset_runtime faset_gameplay)
else()
add_library(faset_gameplay_test_fixture STATIC ${CMAKE_CURRENT_LIST_DIR}/../examples/gameplay/Gameplay.cpp)
target_include_directories(faset_gameplay_test_fixture PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../examples/gameplay)
target_link_libraries(faset_gameplay_test_fixture PUBLIC faset_runtime)
target_link_libraries(faset_runtime_tests PRIVATE faset_runtime faset_gameplay_test_fixture)
endif()
add_test(NAME runtime_contracts COMMAND faset_runtime_tests)
endif()