2017-11-05 09:15:22 +01:00
|
|
|
#
|
|
|
|
# Build examples.
|
|
|
|
#
|
2018-01-18 19:20:08 +01:00
|
|
|
# Requires CATCH_BUILD_EXAMPLES to be defined 'true', see ../CMakeLists.txt.
|
2017-11-05 09:15:22 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
cmake_minimum_required( VERSION 3.0 )
|
|
|
|
|
|
|
|
project( CatchExamples CXX )
|
|
|
|
|
2018-09-08 20:15:51 +02:00
|
|
|
message( STATUS "Examples included" )
|
|
|
|
|
2017-11-05 09:15:22 +01:00
|
|
|
# define folders used:
|
|
|
|
|
|
|
|
set( EXAMPLES_DIR ${CATCH_DIR}/examples )
|
|
|
|
set( HEADER_DIR ${CATCH_DIR}/single_include )
|
2017-11-29 21:22:38 +01:00
|
|
|
set( REPORTER_HEADER_DIR ${CATCH_DIR}/include/reporters )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
# single-file sources:
|
|
|
|
|
|
|
|
set( SOURCES_SINGLE_FILE
|
|
|
|
010-TestCase.cpp
|
2018-07-08 13:35:40 +02:00
|
|
|
231-Cfg-OutputStreams.cpp
|
2017-11-05 09:15:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# multiple-file modules:
|
|
|
|
|
|
|
|
set( SOURCES_020
|
|
|
|
020-TestCase-1.cpp
|
|
|
|
020-TestCase-2.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# main for idiomatic test sources:
|
|
|
|
|
|
|
|
set( SOURCES_IDIOMATIC_MAIN
|
|
|
|
000-CatchMain.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# sources to combine with 000-CatchMain.cpp:
|
|
|
|
|
|
|
|
set( SOURCES_IDIOMATIC_TESTS
|
|
|
|
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
|
|
|
)
|
|
|
|
|
2017-11-29 21:22:38 +01:00
|
|
|
# main-s for reporter-specific test sources:
|
|
|
|
|
|
|
|
set( SOURCES_REPORTERS_MAIN
|
|
|
|
200-Rpt-CatchMain.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN 200-Rpt-CatchMain.cpp )
|
|
|
|
|
|
|
|
set( NAMES_REPORTERS TeamCity )
|
|
|
|
|
|
|
|
foreach( reporter ${NAMES_REPORTERS} )
|
|
|
|
list( APPEND SOURCES_SPECIFIC_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN}${reporter}.cpp )
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# sources to combine with 200-Rpt-CatchMain{Reporter}.cpp:
|
|
|
|
|
|
|
|
set( SOURCES_REPORTERS_TESTS
|
|
|
|
207-Rpt-TeamCityReporter.cpp
|
|
|
|
)
|
|
|
|
|
2017-11-05 09:15:22 +01:00
|
|
|
# check if all sources are listed, warn if not:
|
|
|
|
|
|
|
|
set( SOURCES_ALL
|
|
|
|
${SOURCES_020}
|
|
|
|
${SOURCES_SINGLE_FILE}
|
|
|
|
${SOURCES_IDIOMATIC_MAIN}
|
|
|
|
${SOURCES_IDIOMATIC_TESTS}
|
2017-11-29 21:22:38 +01:00
|
|
|
${SOURCES_REPORTERS_MAIN}
|
|
|
|
${SOURCES_REPORTERS_TESTS}
|
2017-11-05 09:15:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
foreach( name ${SOURCES_ALL} )
|
|
|
|
list( APPEND SOURCES_ALL_PATH ${EXAMPLES_DIR}/${name} )
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
CheckFileList( SOURCES_ALL_PATH ${EXAMPLES_DIR} )
|
|
|
|
|
|
|
|
# create target names:
|
|
|
|
|
|
|
|
string( REPLACE ".cpp" "" BASENAMES_SINGLE_FILE "${SOURCES_SINGLE_FILE}" )
|
|
|
|
string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_TESTS "${SOURCES_IDIOMATIC_TESTS}" )
|
2017-11-29 21:22:38 +01:00
|
|
|
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_TESTS "${SOURCES_REPORTERS_TESTS}" )
|
|
|
|
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN "${SOURCES_REPORTERS_MAIN}" )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
set( TARGETS_SINGLE_FILE ${BASENAMES_SINGLE_FILE} )
|
|
|
|
set( TARGETS_IDIOMATIC_TESTS ${BASENAMES_IDIOMATIC_TESTS} )
|
2017-11-29 21:22:38 +01:00
|
|
|
set( TARGETS_REPORTERS_TESTS ${BASENAMES_REPORTERS_TESTS} )
|
|
|
|
set( TARGETS_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN} )
|
|
|
|
|
|
|
|
set( TARGETS_ALL
|
|
|
|
${TARGETS_SINGLE_FILE}
|
|
|
|
020-TestCase
|
|
|
|
${TARGETS_IDIOMATIC_TESTS} CatchMain
|
|
|
|
${TARGETS_REPORTERS_TESTS} CatchMainTeamCity
|
|
|
|
)
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
# define program targets:
|
|
|
|
|
2017-11-29 21:22:38 +01:00
|
|
|
add_library( CatchMain OBJECT ${EXAMPLES_DIR}/${SOURCES_IDIOMATIC_MAIN} ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
#add_library( CatchMainAutomake OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
#add_library( CatchMainTap OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
add_library( CatchMainTeamCity OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
2017-11-29 21:22:38 +01:00
|
|
|
#target_compile_definitions( CatchMainAutomake PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_automake.hpp\" )
|
|
|
|
#target_compile_definitions( CatchMainTap PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_tap.hpp\" )
|
|
|
|
target_compile_definitions( CatchMainTeamCity PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
foreach( name ${TARGETS_SINGLE_FILE} )
|
2018-06-11 10:48:10 +02:00
|
|
|
add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
2017-11-05 09:15:22 +01:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach( name ${TARGETS_IDIOMATIC_TESTS} )
|
2018-06-11 10:48:10 +02:00
|
|
|
add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $<TARGET_OBJECTS:CatchMain> ${HEADER_DIR}/catch2/catch.hpp )
|
2017-11-05 09:15:22 +01:00
|
|
|
endforeach()
|
|
|
|
|
2017-11-29 21:22:38 +01:00
|
|
|
add_executable( 020-TestCase ${EXAMPLES_DIR}/020-TestCase-1.cpp ${EXAMPLES_DIR}/020-TestCase-2.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
|
|
|
|
#add_executable( 207-Rpt-AutomakeReporter ${EXAMPLES_DIR}/207-Rpt-AutomakeReporter.cpp $<TARGET_OBJECTS:CatchMainAutomake> ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
#add_executable( 207-Rpt-TapReporter ${EXAMPLES_DIR}/207-Rpt-TapReporter.cpp $<TARGET_OBJECTS:CatchMainTap> ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
add_executable( 207-Rpt-TeamCityReporter ${EXAMPLES_DIR}/207-Rpt-TeamCityReporter.cpp $<TARGET_OBJECTS:CatchMainTeamCity> ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
|
|
|
|
#foreach( name ${TARGETS_REPORTERS_TESTS} )
|
|
|
|
# add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $<TARGET_OBJECTS:CatchMain> ${HEADER_DIR}/catch2/catch.hpp )
|
|
|
|
#endforeach()
|
|
|
|
|
2017-11-05 09:15:22 +01:00
|
|
|
foreach( name ${TARGETS_ALL} )
|
2017-11-29 21:22:38 +01:00
|
|
|
target_include_directories( ${name} PRIVATE ${HEADER_DIR} ${CATCH_DIR} )
|
2017-11-05 09:15:22 +01:00
|
|
|
|
|
|
|
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
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()
|
2017-11-29 21:22:38 +01:00
|
|
|
|