Files
Catch2/examples/CMakeLists.txt
T

58 lines
1.5 KiB
CMake
Raw Normal View History

2025-04-07 22:09:59 -06:00
cmake_minimum_required(VERSION 3.16)
project(Catch2Examples LANGUAGES CXX)
2025-04-07 22:09:59 -06:00
message(STATUS "Examples included")
2019-12-08 15:55:04 +01:00
# Some one-offs first:
# 1) Tests and main in one file
2025-04-07 22:09:59 -06:00
add_executable(010-TestCase
2019-12-08 15:55:04 +01:00
010-TestCase.cpp
)
2019-12-08 15:55:04 +01:00
# 2) Tests and main across two files
2025-04-07 22:09:59 -06:00
add_executable(020-MultiFile
2019-12-08 15:55:04 +01:00
020-TestCase-1.cpp
020-TestCase-2.cpp
)
2019-12-08 20:57:55 +01:00
add_executable(231-Cfg_OutputStreams
2025-04-07 22:09:59 -06:00
231-Cfg-OutputStreams.cpp
2019-12-08 20:57:55 +01:00
)
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
2019-12-08 15:55:04 +01:00
# These examples use the standard separate compilation
2025-04-07 22:09:59 -06:00
set(SOURCES_IDIOMATIC_EXAMPLES
030-Asn-Require-Check.cpp
100-Fix-Section.cpp
110-Fix-ClassFixture.cpp
111-Fix-PersistentFixture.cpp
120-Bdd-ScenarioGivenWhenThen.cpp
210-Evt-EventListeners.cpp
232-Cfg-CustomMain.cpp
300-Gen-OwnGenerator.cpp
301-Gen-MapTypeConversion.cpp
302-Gen-Table.cpp
310-Gen-VariablesInGenerators.cpp
311-Gen-CustomCapture.cpp
)
2025-04-07 22:09:59 -06:00
string(REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}")
set(TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES})
2025-04-07 22:09:59 -06:00
foreach(name ${TARGETS_IDIOMATIC_EXAMPLES})
add_executable(${name} ${name}.cpp)
endforeach()
2019-12-08 15:55:04 +01:00
set(ALL_EXAMPLE_TARGETS
${TARGETS_IDIOMATIC_EXAMPLES}
010-TestCase
020-MultiFile
)
2025-04-07 22:09:59 -06:00
foreach(name ${ALL_EXAMPLE_TARGETS})
target_link_libraries(${name} Catch2WithMain)
endforeach()
list(APPEND CATCH_WARNING_TARGETS ${ALL_EXAMPLE_TARGETS})
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)