Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cmake/WarningsAsErrors.cmake
Original file line number Diff line number Diff line change
@@ -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("$<BUILD_INTERFACE:${boost_ut_compile_options}>")
unset(boost_ut_compile_options)
39 changes: 27 additions & 12 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <version>
#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 <execution>, 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)
Expand Down
2 changes: 1 addition & 1 deletion include/boost/ut.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export module boost.ut;
import std;

#define BOOST_UT_CXX_MODULES 1
#include <boost/ut.hpp>
#include "boost/ut.hpp"

template class boost::ut::reporter_junit<boost::ut::printer>;
template void boost::ut::reporter_junit<boost::ut::printer>::on<bool>(boost::ut::events::log<bool>);
Expand Down
Loading