mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
Redo how the separate compilation tests are handled
This commit is contained in:
parent
8b42acc328
commit
5fbf04cd59
@ -36,7 +36,7 @@ set(BENCHMARK_DIR ${CATCH_DIR}/tests/Benchmark)
|
|||||||
set(EXAMPLES_DIR ${CATCH_DIR}/examples)
|
set(EXAMPLES_DIR ${CATCH_DIR}/examples)
|
||||||
|
|
||||||
# We need to bring-in the variables defined there to this scope
|
# We need to bring-in the variables defined there to this scope
|
||||||
include(src/CMakeLists.txt)
|
add_subdirectory(src)
|
||||||
|
|
||||||
# Build tests only if requested
|
# Build tests only if requested
|
||||||
if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT)
|
if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT)
|
||||||
|
@ -20,8 +20,8 @@ add_executable( 020-MultiFile
|
|||||||
add_executable(231-Cfg_OutputStreams
|
add_executable(231-Cfg_OutputStreams
|
||||||
231-Cfg-OutputStreams.cpp
|
231-Cfg-OutputStreams.cpp
|
||||||
)
|
)
|
||||||
StampOutLibrary(231-Cfg_OutputStreams)
|
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
|
||||||
target_compile_definitions(Catch2_231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
|
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
|
||||||
|
|
||||||
# These examples use the standard separate compilation
|
# These examples use the standard separate compilation
|
||||||
set( SOURCES_IDIOMATIC_EXAMPLES
|
set( SOURCES_IDIOMATIC_EXAMPLES
|
||||||
|
@ -230,19 +230,20 @@ target_include_directories(Catch2
|
|||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
|
|
||||||
function(StampOutLibrary target)
|
# Some tests require a full recompilation of Catch2 lib with different
|
||||||
add_library(Catch2_${target} STATIC
|
# compilation flags. They can link against this target to recompile all
|
||||||
|
# the sources into the binary.
|
||||||
|
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||||
|
add_library(Catch2_buildall_interface INTERFACE)
|
||||||
|
target_sources(Catch2_buildall_interface INTERFACE
|
||||||
${REPORTER_FILES}
|
${REPORTER_FILES}
|
||||||
${INTERNAL_FILES}
|
${INTERNAL_FILES}
|
||||||
${BENCHMARK_HEADERS}
|
${BENCHMARK_HEADERS}
|
||||||
${BENCHMARK_SOURCES}
|
${BENCHMARK_SOURCES}
|
||||||
)
|
)
|
||||||
|
target_include_directories(Catch2_buildall_interface
|
||||||
target_include_directories(Catch2_${target}
|
INTERFACE
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
target_link_libraries(${target} Catch2_${target})
|
|
||||||
endfunction()
|
|
||||||
|
@ -53,15 +53,14 @@ add_executable( DisabledExceptions-DefaultHandler ${TESTS_DIR}/X03-DisabledExcep
|
|||||||
add_executable( DisabledExceptions-CustomHandler ${TESTS_DIR}/X04-DisabledExceptions-CustomHandler.cpp )
|
add_executable( DisabledExceptions-CustomHandler ${TESTS_DIR}/X04-DisabledExceptions-CustomHandler.cpp )
|
||||||
|
|
||||||
foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandler)
|
foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandler)
|
||||||
StampOutLibrary(${target})
|
target_compile_options( ${target}
|
||||||
target_compile_options( Catch2_${target}
|
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/EHs-c-;/D_HAS_EXCEPTIONS=0>
|
$<$<CXX_COMPILER_ID:MSVC>:/EHs-c-;/D_HAS_EXCEPTIONS=0>
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:AppleClang>>:-fno-exceptions>
|
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:AppleClang>>:-fno-exceptions>
|
||||||
)
|
)
|
||||||
target_link_libraries(${target} Catch2_${target})
|
target_link_libraries(${target} Catch2_buildall_interface)
|
||||||
endforeach()
|
endforeach()
|
||||||
target_compile_definitions( Catch2_DisabledExceptions-CustomHandler PUBLIC CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER )
|
target_compile_definitions( DisabledExceptions-CustomHandler PUBLIC CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER )
|
||||||
|
|
||||||
|
|
||||||
add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-1 COMMAND DisabledExceptions-DefaultHandler "Tests that run")
|
add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-1 COMMAND DisabledExceptions-DefaultHandler "Tests that run")
|
||||||
@ -121,9 +120,8 @@ set_tests_properties(
|
|||||||
|
|
||||||
|
|
||||||
add_executable(BenchmarkingMacros ${TESTS_DIR}/X20-BenchmarkingMacros.cpp)
|
add_executable(BenchmarkingMacros ${TESTS_DIR}/X20-BenchmarkingMacros.cpp)
|
||||||
StampOutLibrary(BenchmarkingMacros)
|
target_compile_definitions( BenchmarkingMacros PUBLIC CATCH_CONFIG_ENABLE_BENCHMARKING )
|
||||||
target_compile_definitions( Catch2_BenchmarkingMacros PUBLIC CATCH_CONFIG_ENABLE_BENCHMARKING )
|
target_link_libraries( BenchmarkingMacros Catch2_buildall_interface )
|
||||||
target_link_libraries( BenchmarkingMacros Catch2_BenchmarkingMacros )
|
|
||||||
|
|
||||||
add_test(NAME BenchmarkingMacros COMMAND BenchmarkingMacros -r console -s)
|
add_test(NAME BenchmarkingMacros COMMAND BenchmarkingMacros -r console -s)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
|
Loading…
Reference in New Issue
Block a user