| 1 |
cmake_minimum_required( VERSION 3.10 ) |
| 2 |
|
| 3 |
project( Catch2Examples LANGUAGES CXX ) |
| 4 |
|
| 5 |
message( STATUS "Examples included" ) |
| 6 |
|
| 7 |
|
| 8 |
# Some one-offs first: |
| 9 |
# 1) Tests and main in one file |
| 10 |
add_executable( 010-TestCase |
| 11 |
010-TestCase.cpp |
| 12 |
) |
| 13 |
|
| 14 |
# 2) Tests and main across two files |
| 15 |
add_executable( 020-MultiFile |
| 16 |
020-TestCase-1.cpp |
| 17 |
020-TestCase-2.cpp |
| 18 |
) |
| 19 |
|
| 20 |
add_executable(231-Cfg_OutputStreams |
| 21 |
231-Cfg-OutputStreams.cpp |
| 22 |
) |
| 23 |
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface) |
| 24 |
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT) |
| 25 |
|
| 26 |
# These examples use the standard separate compilation |
| 27 |
set( SOURCES_IDIOMATIC_EXAMPLES |
| 28 |
030-Asn-Require-Check.cpp |
| 29 |
100-Fix-Section.cpp |
| 30 |
110-Fix-ClassFixture.cpp |
| 31 |
120-Bdd-ScenarioGivenWhenThen.cpp |
| 32 |
210-Evt-EventListeners.cpp |
| 33 |
300-Gen-OwnGenerator.cpp |
| 34 |
301-Gen-MapTypeConversion.cpp |
| 35 |
302-Gen-Table.cpp |
| 36 |
310-Gen-VariablesInGenerators.cpp |
| 37 |
311-Gen-CustomCapture.cpp |
| 38 |
) |
| 39 |
|
| 40 |
string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" ) |
| 41 |
set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) |
| 42 |
|
| 43 |
|
| 44 |
foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) |
| 45 |
add_executable( ${name} |
| 46 |
${EXAMPLES_DIR}/${name}.cpp ) |
| 47 |
endforeach() |
| 48 |
|
| 49 |
set(ALL_EXAMPLE_TARGETS |
| 50 |
${TARGETS_IDIOMATIC_EXAMPLES} |
| 51 |
010-TestCase |
| 52 |
020-MultiFile |
| 53 |
) |
| 54 |
|
| 55 |
foreach( name ${ALL_EXAMPLE_TARGETS} ) |
| 56 |
target_link_libraries( ${name} Catch2 Catch2WithMain ) |
| 57 |
endforeach() |
| 58 |
|
| 59 |
|
| 60 |
list(APPEND CATCH_WARNING_TARGETS ${ALL_EXAMPLE_TARGETS}) |
| 61 |
set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE) |