diff --git a/CMakeLists.txt b/CMakeLists.txt index c5d86c7f..4985beef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,8 @@ set(SELF_TEST_DIR ${CATCH_DIR}/tests/SelfTest) set(BENCHMARK_DIR ${CATCH_DIR}/tests/Benchmark) set(EXAMPLES_DIR ${CATCH_DIR}/examples) -add_subdirectory(src) +# We need to bring-in the variables defined there to this scope +include(src/CMakeLists.txt) # Build tests only if requested if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT) diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp index 2f42c297..8753fcf6 100644 --- a/examples/231-Cfg-OutputStreams.cpp +++ b/examples/231-Cfg-OutputStreams.cpp @@ -6,10 +6,12 @@ // there is no important difference between having `std::cerr` buffered // or unbuffered. -#define CATCH_CONFIG_NOSTDOUT -#define CATCH_CONFIG_MAIN +#include + #include +#include +#include class out_buff : public std::stringbuf { std::FILE* m_stream; diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 2fe5e688..b8612581 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,8 +17,11 @@ add_executable( 020-MultiFile 020-TestCase-2.cpp ) -# TODO: How to handle differently configured libraries? -# Needed in 231-Cfg-OutputStreams +add_executable(231-Cfg_OutputStreams + 231-Cfg-OutputStreams.cpp +) +StampOutLibrary(231-Cfg_OutputStreams) +target_compile_definitions(Catch2_231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT) # These examples use the standard separate compilation set( SOURCES_IDIOMATIC_EXAMPLES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3909d481..227943b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -229,3 +229,20 @@ target_include_directories(Catch2 $ $ ) + +function(StampOutLibrary target) + add_library(Catch2_${target} STATIC + ${REPORTER_FILES} + ${INTERNAL_FILES} + ${BENCHMARK_HEADERS} + ${BENCHMARK_SOURCES} + ) + + target_include_directories(Catch2_${target} + PUBLIC + $ + $ + ) + + target_link_libraries(${target} Catch2_${target}) +endfunction()