2022-09-16 17:56:00 +02:00
|
|
|
cmake_minimum_required( VERSION 3.10 )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
project( Catch2Examples LANGUAGES CXX )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2018-09-08 20:15:51 +02:00
|
|
|
message( STATUS "Examples included" )
|
|
|
|
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
# Some one-offs first:
|
|
|
|
# 1) Tests and main in one file
|
|
|
|
add_executable( 010-TestCase
|
|
|
|
010-TestCase.cpp
|
2017-11-05 09:15:22 +01:00
|
|
|
)
|
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
# 2) Tests and main across two files
|
|
|
|
add_executable( 020-MultiFile
|
|
|
|
020-TestCase-1.cpp
|
|
|
|
020-TestCase-2.cpp
|
2017-11-05 09:15:22 +01:00
|
|
|
)
|
|
|
|
|
2019-12-08 20:57:55 +01:00
|
|
|
add_executable(231-Cfg_OutputStreams
|
|
|
|
231-Cfg-OutputStreams.cpp
|
|
|
|
)
|
2019-12-15 20:33:39 +01:00
|
|
|
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
|
|
|
|
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
# These examples use the standard separate compilation
|
|
|
|
set( SOURCES_IDIOMATIC_EXAMPLES
|
2017-11-05 09:15:22 +01:00
|
|
|
030-Asn-Require-Check.cpp
|
|
|
|
100-Fix-Section.cpp
|
|
|
|
110-Fix-ClassFixture.cpp
|
|
|
|
120-Bdd-ScenarioGivenWhenThen.cpp
|
|
|
|
210-Evt-EventListeners.cpp
|
2019-01-29 10:52:28 +01:00
|
|
|
300-Gen-OwnGenerator.cpp
|
2019-02-26 12:46:10 +01:00
|
|
|
301-Gen-MapTypeConversion.cpp
|
2020-06-19 16:32:08 +02:00
|
|
|
302-Gen-Table.cpp
|
2019-01-29 10:52:28 +01:00
|
|
|
310-Gen-VariablesInGenerators.cpp
|
2019-03-31 14:11:10 +02:00
|
|
|
311-Gen-CustomCapture.cpp
|
2017-11-05 09:15:22 +01:00
|
|
|
)
|
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" )
|
|
|
|
set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} )
|
|
|
|
add_executable( ${name}
|
|
|
|
${EXAMPLES_DIR}/${name}.cpp )
|
2017-11-05 09:15:22 +01:00
|
|
|
endforeach()
|
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
set(ALL_EXAMPLE_TARGETS
|
|
|
|
${TARGETS_IDIOMATIC_EXAMPLES}
|
|
|
|
010-TestCase
|
|
|
|
020-MultiFile
|
2017-11-29 21:22:38 +01:00
|
|
|
)
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2019-12-08 15:55:04 +01:00
|
|
|
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
2020-05-03 18:54:38 +02:00
|
|
|
target_link_libraries( ${name} Catch2 Catch2WithMain )
|
2019-11-06 11:59:50 +01:00
|
|
|
set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
|
2018-08-28 10:12:50 +02:00
|
|
|
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
2017-11-05 09:15:22 +01:00
|
|
|
endforeach()
|
2020-02-21 21:15:45 +01:00
|
|
|
|
|
|
|
|
|
|
|
list(APPEND CATCH_WARNING_TARGETS ${ALL_EXAMPLE_TARGETS})
|
|
|
|
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)
|