Consolidate framework-core+framework-system -> framework. Change qw-test binary to unit-tests. Improve comments
This commit is contained in:
parent
c27378d918
commit
802372fb4a
@ -1,4 +1,5 @@
|
||||
add_subdirectory(framework)
|
||||
add_subdirectory(game)
|
||||
add_subdirectory(editors)
|
||||
|
||||
if (ENABLE_TESTS)
|
||||
@ -8,10 +9,7 @@ if (ENABLE_TESTS)
|
||||
COMMAND ctest -C $CONFIGURATION --test-dir ./tests --output-on-failure
|
||||
)
|
||||
add_dependencies(ctest
|
||||
framework-tests
|
||||
unit-tests
|
||||
copy_assets
|
||||
)
|
||||
endif()
|
||||
|
||||
#add_subdirectory(game)
|
||||
#add_subdirectory(editors)
|
||||
|
@ -8,21 +8,21 @@ set(object-editor_SOURCES
|
||||
|
||||
add_executable(object-editor ${object-editor_SOURCES})
|
||||
|
||||
set_target_properties(object-editor PROPERTIES
|
||||
set_target_properties(object-editor
|
||||
PROPERTIES
|
||||
AUTOMOC TRUE
|
||||
AUTOUIC TRUE
|
||||
)
|
||||
|
||||
target_include_directories(object-editor PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/tests
|
||||
${CMAKE_SOURCE_DIR}/src/tests/common
|
||||
${Catch2_INCLUDE_DIRS}
|
||||
target_include_directories(object-editor
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/
|
||||
)
|
||||
|
||||
|
||||
# Link the test executable with libframework_static source code and Catch2
|
||||
target_link_libraries(object-editor PRIVATE
|
||||
framework-core
|
||||
target_link_libraries(object-editor
|
||||
PRIVATE
|
||||
framework
|
||||
Catch2::Catch2WithMain
|
||||
FakeIt::FakeIt-catch
|
||||
Qt6::Core
|
||||
|
@ -5,7 +5,8 @@ set(FRAMEWORK_SOURCES
|
||||
core/components/EntityManager.cpp
|
||||
core/components/PlayerBehavior.cpp
|
||||
core/components/PositionAttribute.cpp
|
||||
core/input/EventDispatcher.cpp)
|
||||
core/input/EventDispatcher.cpp
|
||||
system/sdl.cpp)
|
||||
|
||||
set(FRAMEWORK_LINK_LIBS
|
||||
${STACKTRACE_DEP_LIBS}
|
||||
@ -15,34 +16,35 @@ set(FRAMEWORK_LINK_LIBS
|
||||
)
|
||||
list(REMOVE_DUPLICATES FRAMEWORK_LINK_LIBS)
|
||||
|
||||
add_library(framework-core SHARED ${FRAMEWORK_SOURCES})
|
||||
add_library(framework-core_static STATIC ${FRAMEWORK_SOURCES})
|
||||
add_library(framework-core_test STATIC ${FRAMEWORK_SOURCES})
|
||||
add_library(framework SHARED ${FRAMEWORK_SOURCES})
|
||||
add_library(framework_static STATIC ${FRAMEWORK_SOURCES})
|
||||
add_library(framework_test STATIC ${FRAMEWORK_SOURCES})
|
||||
|
||||
target_compile_options(framework-core PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(framework-core_static PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(framework-core_test PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(framework PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(framework_static PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
target_compile_options(framework_test PRIVATE ${CMAKE_CXX_FLAGS})
|
||||
|
||||
target_compile_definitions(framework-core_test PUBLIC -DUNIT_TEST=1)
|
||||
|
||||
# Check if the system is Linux
|
||||
set_target_properties(framework-core_static PROPERTIES
|
||||
CMAKE_POSITION_INDEPENDENT_CODE OFF # This forces all linkages to be static (?)
|
||||
# This forces all linkages to be static, I think?
|
||||
set_target_properties(framework_static
|
||||
PROPERTIES
|
||||
CMAKE_POSITION_INDEPENDENT_CODE OFF
|
||||
)
|
||||
set_target_properties(framework-core_test PROPERTIES
|
||||
CMAKE_POSITION_INDEPENDENT_CODE OFF # This forces all linkages to be static (?)
|
||||
set_target_properties(framework_test
|
||||
PROPERTIES
|
||||
CMAKE_POSITION_INDEPENDENT_CODE OFF
|
||||
)
|
||||
target_compile_definitions(framework-core_test PRIVATE -DTESTING)
|
||||
|
||||
# Sets a preprocessor flag for the "testing" build of the library
|
||||
# this activates code paths that are ignored in release or debug builds
|
||||
target_compile_definitions(framework_test PUBLIC -DUNIT_TEST=1)
|
||||
|
||||
# add -rdynamic link option for Boost::stacktrace on Linux
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# Add the -rdynamic linker option
|
||||
target_link_options(framework-core PUBLIC -rdynamic)
|
||||
target_link_options(framework-core_static PUBLIC -rdynamic)
|
||||
target_link_options(framework-core_test PUBLIC -rdynamic)
|
||||
target_link_options(framework PUBLIC -rdynamic)
|
||||
target_link_options(framework_static PUBLIC -rdynamic)
|
||||
target_link_options(framework_test PUBLIC -rdynamic)
|
||||
endif()
|
||||
|
||||
target_link_libraries(framework-core PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
target_link_libraries(framework-core_static PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
target_link_libraries(framework-core_test PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
target_link_libraries(framework PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
target_link_libraries(framework_static PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
target_link_libraries(framework_test PUBLIC ${FRAMEWORK_LINK_LIBS})
|
||||
|
13
src/game/CMakeLists.txt
Normal file
13
src/game/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
set(game_SOURCES
|
||||
main.cpp
|
||||
QuartzWarriors.cpp
|
||||
)
|
||||
add_executable(game ${game_SOURCES})
|
||||
|
||||
target_include_directories(game PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/
|
||||
)
|
||||
|
||||
target_link_libraries(game PRIVATE
|
||||
framework
|
||||
)
|
@ -1,6 +1,6 @@
|
||||
# Add the test executable
|
||||
|
||||
set(FRAMEWORK_TEST_SOURCE_LIST
|
||||
set(TEST_SOURCE_LIST
|
||||
framework/types/adapters/Sequential.test.cpp
|
||||
framework/core/input/EventDispatcher.test.cpp
|
||||
framework/core/input/InputMapper.test.cpp
|
||||
@ -9,35 +9,35 @@ framework/core/components/EntityManager.test.cpp
|
||||
framework/core/components/PositionAttribute.test.cpp
|
||||
)
|
||||
|
||||
add_executable(framework-tests
|
||||
${FRAMEWORK_TEST_SOURCE_LIST}
|
||||
add_executable(unit-tests
|
||||
${TEST_SOURCE_LIST}
|
||||
)
|
||||
|
||||
set_target_properties(framework-tests PROPERTIES
|
||||
set_target_properties(unit-tests PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build/tests"
|
||||
)
|
||||
|
||||
target_compile_definitions(framework-tests PUBLIC -DUNIT_TEST=1)
|
||||
target_include_directories(framework-tests PRIVATE
|
||||
target_compile_definitions(unit-tests PUBLIC -DUNIT_TEST=1)
|
||||
target_include_directories(unit-tests PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/tests
|
||||
${CMAKE_SOURCE_DIR}/src/tests/common
|
||||
${Catch2_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link the test executable with libframework_static source code and Catch2
|
||||
target_link_libraries(framework-tests PRIVATE
|
||||
framework-core_test
|
||||
target_link_libraries(unit-tests PRIVATE
|
||||
framework_test
|
||||
Catch2::Catch2WithMain
|
||||
FakeIt::FakeIt-catch
|
||||
)
|
||||
|
||||
# Extras: Catch2 Ctest integration. @{
|
||||
# add catch2's ctest CMake module and register the tests defined by framework-tests
|
||||
# add catch2's ctest CMake module and register the tests defined by unit-tests
|
||||
# using catch_discover_tests
|
||||
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras)
|
||||
include(CTest)
|
||||
include(Catch)
|
||||
catch_discover_tests(framework-tests)
|
||||
catch_discover_tests(unit-tests)
|
||||
# @}
|
||||
|
||||
# vim: ft=cmake sw=4 ts=4 noet sts=4 foldmethod=marker foldmarker=@{,@}
|
||||
|
Loading…
Reference in New Issue
Block a user