2019-12-08 15:55:04 +01:00
|
|
|
cmake_minimum_required( VERSION 3.5 )
|
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
|
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}
|
|
|
|
000-CatchMain.cpp
|
|
|
|
${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} )
|
|
|
|
target_link_libraries( ${name} Catch2 )
|
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
|
|
|
|
|
|
|
# Add desired warnings
|
|
|
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
|
|
|
target_compile_options( ${name} PRIVATE -Wall -Wextra -Wunreachable-code )
|
|
|
|
endif()
|
|
|
|
# Clang specific warning go here
|
|
|
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
|
|
|
# Actually keep these
|
|
|
|
target_compile_options( ${name} PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
|
|
|
|
endif()
|
|
|
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
|
|
|
target_compile_options( ${name} PRIVATE /W4 /w44265 /WX )
|
|
|
|
endif()
|
|
|
|
endforeach()
|