diff --git a/cmake/WarningsAsErrors.cmake b/cmake/WarningsAsErrors.cmake index c277462b..6b7bbad9 100644 --- a/cmake/WarningsAsErrors.cmake +++ b/cmake/WarningsAsErrors.cmake @@ -1,12 +1,15 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") - add_compile_options(/W4 /WX) + set(boost_ut_compile_options /W4 /WX) elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - add_compile_options(-Wall -Wextra -Wpedantic -Werror -Wshadow) + set(boost_ut_compile_options -Wall -Wextra -Wpedantic -Werror -Wshadow) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0) - add_compile_options(-Wdeprecated-copy-dtor -Wnewline-eof) + set(boost_ut_compile_options -Wdeprecated-copy-dtor -Wnewline-eof) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options(/W4 /WX) + set(boost_ut_compile_options /W4 /WX) endif() + +add_compile_options("$") +unset(boost_ut_compile_options) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index db1b067e..c3dacaa4 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -24,23 +24,38 @@ function(example file target) endif() endfunction() +# Define a test program to detect libstdc++. +# When https://gitlab.kitware.com/cmake/cmake/-/work_items/20851 is complete, +# simply read CMAKE_CXX_STANDARD_LIBRARY variable +include(CheckCXXSourceCompiles) +check_cxx_source_compiles([[ + #include + #ifndef __GLIBCXX__ + #error "not libstdc++" + #endif + int main(){} + ]] + using_glibcxx) + example(cfg/printer printer) example(cfg/runner runner) +example(cfg/reporter reporter) -if(APPLE OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - example(cfg/parallel_runner parallel_runner) +if(using_glibcxx) + # parallel_runner uses , for which libstdc++ requires TBB + find_package(TBB) + if(TBB_FOUND) + example(cfg/parallel_runner parallel_runner) + target_link_libraries(boost_ut_parallel_runner PRIVATE TBB::tbb) + else() + message(AUTHOR_WARNING + "Disabling example/parallel_runner, as it requires TBB when using libstdc++, " + "but TBB could not be found") + endif() +else() + example(cfg/parallel_runner parallel_runner) endif() -# if(DEFINED ENV{TBB_ROOT}) -# set(TBB_ROOT $ENV{TBB_ROOT}) -# # FIXME: include could not find load file: -# include(${TBB_ROOT}/cmake/TBBBuild.cmake) -# tbb_build(TBB_ROOT ${TBB_ROOT} CONFIG_DIR TBB_DIR MAKE_ARGS stdver="c++17") -# find_package(TBB) -# target_link_libraries(boost_ut_parallel_runner ${TBB_IMPORTED_TARGETS}) -# endif() - -example(cfg/reporter reporter) if(NOT WIN32) example(abort abort) diff --git a/include/boost/ut.cppm b/include/boost/ut.cppm index 0625db1d..d3151102 100644 --- a/include/boost/ut.cppm +++ b/include/boost/ut.cppm @@ -9,7 +9,7 @@ export module boost.ut; import std; #define BOOST_UT_CXX_MODULES 1 -#include +#include "boost/ut.hpp" template class boost::ut::reporter_junit; template void boost::ut::reporter_junit::on(boost::ut::events::log);