| 1 |
find_package(Catch2 3.0 REQUIRED) |
| 2 |
find_package(trompeloeil 40 REQUIRED) |
| 3 |
|
| 4 |
# Compile definitions |
| 5 |
list(APPEND TESTS_COMPILE_DEFINITIONS |
| 6 |
${3RDPARTY_DEFINITIONS} |
| 7 |
CATCH_CONFIG_FAST_COMPILE |
| 8 |
SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE |
| 9 |
) |
| 10 |
|
| 11 |
# include directories for all tests |
| 12 |
list(APPEND TESTS_INCLUDE_DIRECTORIES |
| 13 |
${3RDPARTY_INCLUDE_DIRECTORIES} |
| 14 |
${PROJECT_SOURCE_DIR}/src |
| 15 |
) |
| 16 |
|
| 17 |
# catch main |
| 18 |
add_library(catch_main OBJECT "src/main.cpp") |
| 19 |
target_include_directories(catch_main PRIVATE ${TESTS_INCLUDE_DIRECTORIES}) |
| 20 |
target_compile_definitions(catch_main PRIVATE ${TESTS_COMPILE_DEFINITIONS}) |
| 21 |
target_link_libraries(catch_main PRIVATE |
| 22 |
spdlog::spdlog |
| 23 |
Catch2::Catch2 |
| 24 |
trompeloeil::trompeloeil |
| 25 |
${ATOMIC_LIB} |
| 26 |
) |
| 27 |
|
| 28 |
# test_* files |
| 29 |
file(GLOB test_files "src/test_*.cpp") |
| 30 |
|
| 31 |
# generate test_all executable |
| 32 |
add_executable(test_all $<TARGET_OBJECTS:catch_main> ${test_files} ${3RDPARTY_SRC}) |
| 33 |
target_include_directories(test_all PRIVATE ${TESTS_INCLUDE_DIRECTORIES}) |
| 34 |
target_compile_definitions(test_all PRIVATE ${TESTS_COMPILE_DEFINITIONS}) |
| 35 |
target_link_libraries(test_all PRIVATE |
| 36 |
corectrl_lib |
| 37 |
Qt6::Core |
| 38 |
spdlog::spdlog |
| 39 |
$<$<BOOL:${units_FOUND}>:units::units> |
| 40 |
Catch2::Catch2 |
| 41 |
trompeloeil::trompeloeil |
| 42 |
${ATOMIC_LIB} |
| 43 |
) |
| 44 |
|
| 45 |
include(CTest) |
| 46 |
include(Catch) |
| 47 |
catch_discover_tests(test_all) |