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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build*
/.vs
/checks.json
/.vscode
install_dir/
install*/
cmake_build*/
compile_commands.json
.cache/
Expand Down
71 changes: 32 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
option(BOOST_UT_DISABLE_MODULE "Disable ut module" ON)

if(NOT BOOST_UT_DISABLE_MODULE)
cmake_minimum_required(VERSION 4.0.0)
cmake_minimum_required(VERSION 4.0.0)
else()
cmake_minimum_required(VERSION 3.21...3.25)
cmake_minimum_required(VERSION 3.21...3.25)
endif()
project(
ut
Expand All @@ -33,16 +33,9 @@ option(BOOST_UT_BUILD_BENCHMARKS "Build the benchmarks" OFF)
option(BOOST_UT_BUILD_EXAMPLES "Build the examples" ${PROJECT_IS_TOP_LEVEL})
option(BOOST_UT_BUILD_TESTS "Build the tests" ${PROJECT_IS_TOP_LEVEL})
option(BOOST_UT_ENABLE_INSTALL "Enable install targets" ${PROJECT_IS_TOP_LEVEL})
option(BOOST_UT_USE_WARNINGS_AS_ERORS "Build the tests" ${PROJECT_IS_TOP_LEVEL})
option(BOOST_UT_USE_WARNINGS_AS_ERRORS "Treat compile warnings as errors" ${PROJECT_IS_TOP_LEVEL})

add_library(ut INTERFACE)
if(NOT BOOST_UT_DISABLE_MODULE)
add_library(ut_module)
endif()
target_include_directories(ut INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(ut INTERFACE cxx_std_20)

if(BOOST_UT_USE_WARNINGS_AS_ERORS)
if(BOOST_UT_USE_WARNINGS_AS_ERRORS)
include(cmake/WarningsAsErrors.cmake)
endif()

Expand All @@ -66,52 +59,52 @@ if(BOOST_UT_ENABLE_SANITIZERS)
)
endif()

if(BOOST_UT_DISABLE_MODULE)
target_compile_definitions(ut INTERFACE BOOST_UT_DISABLE_MODULE)
endif()

if(NOT BOOST_UT_DISABLE_MODULE)
target_sources(ut_module PUBLIC FILE_SET CXX_MODULES FILES include/boost/ut.cppm)
endif()

add_library(ut INTERFACE)
if(NOT TARGET Boost::ut)
add_library(Boost::ut ALIAS ut)
endif()

if(NOT BOOST_UT_DISABLE_MODULE)
add_library(Boost::ut_module ALIAS ut_module)
endif()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

install(
FILES include/boost/ut.hpp include/boost/ut.cppm
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost
)

target_compile_features(ut INTERFACE cxx_std_20)
target_sources(ut INTERFACE FILE_SET HEADERS BASE_DIRS include FILES include/boost/ut.hpp)
install(
TARGETS ut
EXPORT ut_Targets
INCLUDES DESTINATION include
FILE_SET HEADERS
)

if(BOOST_UT_DISABLE_MODULE)
target_compile_definitions(ut INTERFACE BOOST_UT_DISABLE_MODULE)
else()
include(GNUInstallDirs)

add_library(ut_module)
add_library(Boost::ut_module ALIAS ut_module)
target_compile_features(ut_module PUBLIC cxx_std_23)
set_target_properties(ut_module PROPERTIES CXX_MODULE_STD ON)
target_sources(ut_module PUBLIC FILE_SET CXX_MODULES BASE_DIRS include FILES include/boost/ut.cppm)
target_link_libraries(ut_module PUBLIC Boost::ut)
install(
TARGETS ut_module
EXPORT ut_Targets
FILE_SET CXX_MODULES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

install(
EXPORT ut_Targets
FILE utConfig.cmake
NAMESPACE Boost::
DESTINATION lib/cmake/ut
CXX_MODULES_DIRECTORY "."
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"utConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install(
FILES "${PROJECT_BINARY_DIR}/utConfigVersion.cmake"
DESTINATION lib/cmake/ut
COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT
)
install(FILES "${PROJECT_BINARY_DIR}/utConfigVersion.cmake" DESTINATION lib/cmake/ut)

if(EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".js")
Expand Down
4 changes: 2 additions & 2 deletions include/boost/ut.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ module;
#endif

export module boost.ut;
export import std;
import std;

#define BOOST_UT_CXX_MODULES 1
#include "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
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ endif()

add_subdirectory(ut)
add_subdirectory(ft)
if(TARGET Boost::ut_module)
add_subdirectory(ut-module)
endif()
16 changes: 16 additions & 0 deletions test/ut-module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# not using ut_add_custom_command_or_test() to explicitly link against Boost:ut_module
add_executable(from-ut-module main.cpp)
target_compile_features(from-ut-module PRIVATE cxx_std_20)
target_link_libraries(from-ut-module PRIVATE Boost::ut_module)
set_target_properties(from-ut-module PROPERTIES CXX_SCAN_FOR_MODULES ON)

if(BOOST_UT_ENABLE_RUN_AFTER_BUILD)
add_custom_command(
TARGET from-ut-module
POST_BUILD
COMMAND from-ut-module
COMMENT "Running from-ut-module"
)
else()
add_test(NAME from-ut-module COMMAND from-ut-module)
endif()
18 changes: 18 additions & 0 deletions test/ut-module/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (c) 2019-2020 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
import boost.ut;

int main() {
using namespace boost::ut;

"module"_test = [] {
// clang-format off
expect(42_i == 42 and constant<3 == 3_i>);
// clang-format on
};
}
Loading