From a8a7c37f0a968b06c46382322ad09d86d6b62bcc Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Sun, 22 Dec 2024 12:28:27 +0100 Subject: [PATCH 01/21] Initial implementation --- CMakeLists.txt | 27 +++++++--- include/boost/assert/current_location.hpp | 61 +++++++++++++++++++++++ include/boost/assert/source_location.hpp | 61 +++-------------------- modules/assert.cxx | 10 ++++ 4 files changed, 99 insertions(+), 60 deletions(-) create mode 100644 include/boost/assert/current_location.hpp create mode 100644 modules/assert.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cfd4f4..c374187 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,30 @@ cmake_minimum_required(VERSION 3.5...3.20) project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) -add_library(boost_assert INTERFACE) -add_library(Boost::assert ALIAS boost_assert) - -target_include_directories(boost_assert INTERFACE include) -target_link_libraries(boost_assert - INTERFACE +if (BOOST_CXX20_MODULE) + add_library(boost_assert) + target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES FILES modules/assert.cxx) + target_include_directories(boost_assert PUBLIC include) + target_compile_features(boost_assert PUBLIC cxx_std_23) + set_target_properties(boost_assert PROPERTIES CXX_MODULE_STD 1) + target_compile_definitions(boost_assert PRIVATE BOOST_CXX20_MODULE) + target_compile_options(boost_assert PUBLIC -Wno-include-angled-in-module-purview) # TODO: scope this to clang + target_link_libraries(boost_assert PUBLIC + Boost::config + ) +else() + add_library(boost_assert INTERFACE) + target_include_directories(boost_assert INTERFACE include) + target_link_libraries(boost_assert + INTERFACE Boost::config ) +endif() + + +add_library(Boost::assert ALIAS boost_assert) + if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio") diff --git a/include/boost/assert/current_location.hpp b/include/boost/assert/current_location.hpp new file mode 100644 index 0000000..7e85544 --- /dev/null +++ b/include/boost/assert/current_location.hpp @@ -0,0 +1,61 @@ +#ifndef BOOST_ASSERT_CURRENT_LOCATION_HPP_INCLUDED +#define BOOST_ASSERT_CURRENT_LOCATION_HPP_INCLUDED + + +#include + +#if defined(BOOST_DISABLE_CURRENT_LOCATION) + +# define BOOST_CURRENT_LOCATION ::boost::source_location() + +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1935 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCSIG(), __builtin_COLUMN()) + +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 + +// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce +// the correct result under 19.31, so prefer the built-ins +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) + +#elif defined(BOOST_MSVC) + +// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before + +# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x) +# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10) + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "") + +#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__) + +// Under nvcc, __builtin_source_location is not constexpr +// https://github.com/boostorg/assert/issues/32 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current()) + +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) + +#elif defined(BOOST_GCC) && BOOST_GCC >= 80000 + +// The built-ins are available in 4.8+, but are not constant expressions until 7 +// In addition, reproducible builds require -ffile-prefix-map, which is GCC 8 +// https://github.com/boostorg/assert/issues/38 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION()) + +#elif defined(BOOST_GCC) && BOOST_GCC >= 50000 + +// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__) + +#else + +// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "") + +#endif + +#endif \ No newline at end of file diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index c6eae32..2c22f73 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -7,6 +7,9 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#include // BOOST_MODULE_EXPORT + +#ifndef BOOST_CXX20_MODULE #include #include #include @@ -17,11 +20,12 @@ #if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L # include #endif +#endif namespace boost { -struct source_location +BOOST_MODULE_EXPORT struct source_location { private: @@ -132,6 +136,7 @@ struct source_location } }; +BOOST_MODULE_EXPORT template std::basic_ostream & operator<<( std::basic_ostream & os, source_location const & loc ) { os << loc.to_string(); @@ -140,58 +145,6 @@ template std::basic_ostream & operator<<( std::basic_ost } // namespace boost -#if defined(BOOST_DISABLE_CURRENT_LOCATION) - -# define BOOST_CURRENT_LOCATION ::boost::source_location() - -#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1935 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCSIG(), __builtin_COLUMN()) - -#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 - -// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce -// the correct result under 19.31, so prefer the built-ins -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) - -#elif defined(BOOST_MSVC) - -// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before - -# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x) -# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10) - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "") - -#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__) - -// Under nvcc, __builtin_source_location is not constexpr -// https://github.com/boostorg/assert/issues/32 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current()) - -#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) - -#elif defined(BOOST_GCC) && BOOST_GCC >= 80000 - -// The built-ins are available in 4.8+, but are not constant expressions until 7 -// In addition, reproducible builds require -ffile-prefix-map, which is GCC 8 -// https://github.com/boostorg/assert/issues/38 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION()) - -#elif defined(BOOST_GCC) && BOOST_GCC >= 50000 - -// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#else - -// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "") - -#endif +#include #endif // #ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED diff --git a/modules/assert.cxx b/modules/assert.cxx new file mode 100644 index 0000000..bce7f49 --- /dev/null +++ b/modules/assert.cxx @@ -0,0 +1,10 @@ +module; + +#include +#include + +export module boost.assert; + +import std; + +#include From 09da380ce883ca2845fd7d9c577de6bc6c8a94f8 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Sun, 22 Dec 2024 13:13:16 +0100 Subject: [PATCH 02/21] Reduce CMake duplication --- CMakeLists.txt | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c374187..c01c325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,28 +9,22 @@ project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) if (BOOST_CXX20_MODULE) - add_library(boost_assert) + add_library(boost_assert STATIC) + boost_set_cxx20_module_settings(boost_assert) target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES FILES modules/assert.cxx) - target_include_directories(boost_assert PUBLIC include) - target_compile_features(boost_assert PUBLIC cxx_std_23) - set_target_properties(boost_assert PROPERTIES CXX_MODULE_STD 1) - target_compile_definitions(boost_assert PRIVATE BOOST_CXX20_MODULE) - target_compile_options(boost_assert PUBLIC -Wno-include-angled-in-module-purview) # TODO: scope this to clang - target_link_libraries(boost_assert PUBLIC - Boost::config - ) + set(__scope PUBLIC) else() add_library(boost_assert INTERFACE) - target_include_directories(boost_assert INTERFACE include) - target_link_libraries(boost_assert - INTERFACE - Boost::config -) + set(__scope INTERFACE) endif() add_library(Boost::assert ALIAS boost_assert) - +target_include_directories(boost_assert ${__scope} include) +target_link_libraries(boost_assert + ${__scope} + Boost::config +) if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio") From e60839e02f72749c0904c91f86eeade17b2890b4 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Mon, 30 Dec 2024 10:47:28 +0100 Subject: [PATCH 03/21] Rename module to boost_xxx.cpppm --- CMakeLists.txt | 2 +- modules/{assert.cxx => boost_assert.cppm} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename modules/{assert.cxx => boost_assert.cppm} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c01c325..a85e076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) if (BOOST_CXX20_MODULE) add_library(boost_assert STATIC) boost_set_cxx20_module_settings(boost_assert) - target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES FILES modules/assert.cxx) + target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES FILES modules/boost_assert.cppm) set(__scope PUBLIC) else() add_library(boost_assert INTERFACE) diff --git a/modules/assert.cxx b/modules/boost_assert.cppm similarity index 100% rename from modules/assert.cxx rename to modules/boost_assert.cppm From ca3d8cce8c68390b9cee04abf4980a7149dff609 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Mon, 30 Dec 2024 10:56:20 +0100 Subject: [PATCH 04/21] BASE_DIRS --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a85e076..97e44a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) if (BOOST_CXX20_MODULE) add_library(boost_assert STATIC) boost_set_cxx20_module_settings(boost_assert) - target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES FILES modules/boost_assert.cppm) + target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_assert.cppm) set(__scope PUBLIC) else() add_library(boost_assert INTERFACE) From 0552833eca17d43317ad6b6700dea04e60e6730f Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Mon, 30 Dec 2024 10:58:49 +0100 Subject: [PATCH 05/21] extern C++ --- modules/boost_assert.cppm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/boost_assert.cppm b/modules/boost_assert.cppm index bce7f49..34a366f 100644 --- a/modules/boost_assert.cppm +++ b/modules/boost_assert.cppm @@ -7,4 +7,6 @@ export module boost.assert; import std; +extern "C++" { #include +} From 5cd67d606241eadc63e194383175e3420b8d7922 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Mon, 30 Dec 2024 11:21:25 +0100 Subject: [PATCH 06/21] Rename config macro to BOOST_USE_MODULES --- CMakeLists.txt | 2 +- include/boost/assert/source_location.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97e44a1..ac149a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ cmake_minimum_required(VERSION 3.5...3.20) project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) -if (BOOST_CXX20_MODULE) +if (BOOST_USE_MODULES) add_library(boost_assert STATIC) boost_set_cxx20_module_settings(boost_assert) target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_assert.cppm) diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index 2c22f73..4649734 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -9,7 +9,7 @@ #include // BOOST_MODULE_EXPORT -#ifndef BOOST_CXX20_MODULE +#ifndef BOOST_USE_MODULES #include #include #include From 32f37b3694d29a3cb2af2f0a5fe052e47558a664 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Fri, 3 Jan 2025 17:31:33 +0100 Subject: [PATCH 07/21] Move away from BOOST_MODULE_EXPORT --- include/boost/assert/source_location.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index 4649734..e5fe84e 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -7,8 +7,6 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt -#include // BOOST_MODULE_EXPORT - #ifndef BOOST_USE_MODULES #include #include @@ -22,10 +20,18 @@ #endif #endif +// BOOST_ASSERT_MODULE_EXPORT + +#ifdef BOOST_USE_MODULES +# define BOOST_ASSERT_MODULE_EXPORT export +#else +# define BOOST_ASSERT_MODULE_EXPORT +#endif + namespace boost { -BOOST_MODULE_EXPORT struct source_location +BOOST_ASSERT_MODULE_EXPORT struct source_location { private: @@ -136,7 +142,7 @@ BOOST_MODULE_EXPORT struct source_location } }; -BOOST_MODULE_EXPORT +BOOST_ASSERT_MODULE_EXPORT template std::basic_ostream & operator<<( std::basic_ostream & os, source_location const & loc ) { os << loc.to_string(); From 3f3f0784de1c0e17d0b69672eea776363dc5f621 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Fri, 10 Jan 2025 19:39:44 +0100 Subject: [PATCH 08/21] Move away from CMake common function --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac149a3..f67ecf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,9 +10,20 @@ project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) if (BOOST_USE_MODULES) add_library(boost_assert STATIC) - boost_set_cxx20_module_settings(boost_assert) target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_assert.cppm) set(__scope PUBLIC) + + # Enable and propagate C++23, import std, and the modules macro + target_compile_features(boost_assert PUBLIC cxx_std_23) + set_target_properties(boost_assert PROPERTIES CXX_MODULE_STD 1) + target_compile_definitions(boost_assert PUBLIC BOOST_USE_MODULES) + + # Silence warnings about includes in the purview + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(boost_assert PRIVATE -Wno-include-angled-in-module-purview) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(boost_assert PRIVATE /wd5244) + endif() else() add_library(boost_assert INTERFACE) set(__scope INTERFACE) From 0229101f15396b28ee5811f1bb4a4444e49f3653 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Tue, 24 Feb 2026 12:27:08 +0100 Subject: [PATCH 09/21] Migrate to new approach --- CMakeLists.txt | 7 ------- include/boost/assert/source_location.hpp | 26 +++++++++++++++++------- modules/boost_assert.cppm | 14 +++++++++++-- test/exp/verify_msg_exp_test.cpp | 2 +- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3263082..91bba7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,13 +17,6 @@ if (BOOST_USE_MODULES) target_compile_features(boost_assert PUBLIC cxx_std_23) set_target_properties(boost_assert PROPERTIES CXX_MODULE_STD 1) target_compile_definitions(boost_assert PUBLIC BOOST_USE_MODULES) - - # Silence warnings about includes in the purview - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(boost_assert PRIVATE -Wno-include-angled-in-module-purview) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(boost_assert PRIVATE /wd5244) - endif() else() add_library(boost_assert INTERFACE) set(__scope INTERFACE) diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index ec0b9a5..a117519 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -7,24 +7,31 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#if defined(BOOST_USE_MODULES) && !defined(BOOST_ASSERT_INTERFACE_UNIT) + +#ifndef BOOST_ASSERT_SKIP_IMPORT +import boost.assert; +#endif + +#else + #ifndef BOOST_USE_MODULES #include #include -#include -#include -#include +#endif +#include +#include +#include #if !defined(BOOST_NO_IOSTREAM) -#include +#include #endif #if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L -# include -#endif +# include #endif // BOOST_ASSERT_MODULE_EXPORT - #ifdef BOOST_USE_MODULES # define BOOST_ASSERT_MODULE_EXPORT export #else @@ -158,6 +165,11 @@ template std::basic_ostream & operator<<( std::basic_ost } // namespace boost +#endif // Modules compatibility header + +// Not safe to include in the interface unit because of includes, and not needed +#if !defined(BOOST_ASSERT_INTERFACE_UNIT) #include +#endif #endif // #ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED diff --git a/modules/boost_assert.cppm b/modules/boost_assert.cppm index 34a366f..9d5b78a 100644 --- a/modules/boost_assert.cppm +++ b/modules/boost_assert.cppm @@ -7,6 +7,16 @@ export module boost.assert; import std; -extern "C++" { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 5244) +#endif + +#define BOOST_ASSERT_INTERFACE_UNIT +#define BOOST_CONFIG_SKIP_IMPORT_STD #include -} diff --git a/test/exp/verify_msg_exp_test.cpp b/test/exp/verify_msg_exp_test.cpp index 02090fe..4047860 100644 --- a/test/exp/verify_msg_exp_test.cpp +++ b/test/exp/verify_msg_exp_test.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include // default case, !NDEBUG // BOOST_VERIFY_MSG(x,"m") -> BOOST_ASSERT_MSG(x,"m") From c98f91a33e9d6b0b65c2520f91f319e56121345a Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Tue, 24 Feb 2026 12:58:42 +0100 Subject: [PATCH 10/21] test suite --- test/CMakeLists.txt | 4 ++++ test/assert_test.cpp | 2 +- test/check_cmake_version.cpp | 2 +- test/current_function_test.cpp | 2 +- test/current_function_test2.cpp | 2 +- test/exp/assert_exp_test.cpp | 2 +- test/exp/assert_msg_exp_test.cpp | 2 +- test/exp/verify_exp_test.cpp | 2 +- test/source_location_test.cpp | 2 +- test/source_location_test3.cpp | 4 ++-- test/source_location_test4.cpp | 2 +- test/source_location_test5.cpp | 2 +- test/verify_test.cpp | 2 +- 13 files changed, 17 insertions(+), 13 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8703c22..d90982c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,6 +6,10 @@ include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) if(HAVE_BOOST_TEST) +if(BOOST_USE_MODULES) + set(CMAKE_CXX_MODULE_STD ON) +endif() + boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::assert Boost::core) endif() diff --git a/test/assert_test.cpp b/test/assert_test.cpp index 5e440f5..a36d6f4 100644 --- a/test/assert_test.cpp +++ b/test/assert_test.cpp @@ -72,7 +72,7 @@ void test_disabled() #define BOOST_ENABLE_ASSERT_HANDLER #include #include -#include +#include int handler_invoked = 0; int msg_handler_invoked = 0; diff --git a/test/check_cmake_version.cpp b/test/check_cmake_version.cpp index 2fd4648..708f7ce 100644 --- a/test/check_cmake_version.cpp +++ b/test/check_cmake_version.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include int main( int ac, char const* av[] ) { diff --git a/test/current_function_test.cpp b/test/current_function_test.cpp index c664696..c265321 100644 --- a/test/current_function_test.cpp +++ b/test/current_function_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include void message(char const * file, long line, char const * func, char const * msg) { diff --git a/test/current_function_test2.cpp b/test/current_function_test2.cpp index e3c2523..484a9ac 100644 --- a/test/current_function_test2.cpp +++ b/test/current_function_test2.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include int f() { diff --git a/test/exp/assert_exp_test.cpp b/test/exp/assert_exp_test.cpp index c56cdef..61c8903 100644 --- a/test/exp/assert_exp_test.cpp +++ b/test/exp/assert_exp_test.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include // Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled static std::string quote( std::string const & s ) diff --git a/test/exp/assert_msg_exp_test.cpp b/test/exp/assert_msg_exp_test.cpp index faff616..4b96068 100644 --- a/test/exp/assert_msg_exp_test.cpp +++ b/test/exp/assert_msg_exp_test.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include // Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled static std::string quote( std::string const & s ) diff --git a/test/exp/verify_exp_test.cpp b/test/exp/verify_exp_test.cpp index 844513b..13c0be5 100644 --- a/test/exp/verify_exp_test.cpp +++ b/test/exp/verify_exp_test.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include // default case, !NDEBUG // BOOST_VERIFY(x) -> BOOST_ASSERT(x) diff --git a/test/source_location_test.cpp b/test/source_location_test.cpp index e3e7311..1ecde1f 100644 --- a/test/source_location_test.cpp +++ b/test/source_location_test.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include static char const* adjust_filename( char const* file ) { diff --git a/test/source_location_test3.cpp b/test/source_location_test3.cpp index 810c3ee..8f218b9 100644 --- a/test/source_location_test3.cpp +++ b/test/source_location_test3.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include static char const* adjust_filename( char const* file ) { diff --git a/test/source_location_test4.cpp b/test/source_location_test4.cpp index 1242314..a0928a7 100644 --- a/test/source_location_test4.cpp +++ b/test/source_location_test4.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include static char const* adjust_filename( char const* file ) { diff --git a/test/source_location_test5.cpp b/test/source_location_test5.cpp index ef8a0dc..443d259 100644 --- a/test/source_location_test5.cpp +++ b/test/source_location_test5.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include template class result { diff --git a/test/verify_test.cpp b/test/verify_test.cpp index ea46d53..74f0b8d 100644 --- a/test/verify_test.cpp +++ b/test/verify_test.cpp @@ -67,7 +67,7 @@ void test_disabled() #define BOOST_ENABLE_ASSERT_HANDLER #include #include -#include +#include int handler_invoked = 0; From 2553571f9ba5265644aedaf6cadfc57abb9067f4 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Tue, 24 Feb 2026 13:06:22 +0100 Subject: [PATCH 11/21] gcc fixes --- test/assert_msg_test2.cpp | 2 +- test/assert_test2.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/assert_msg_test2.cpp b/test/assert_msg_test2.cpp index f079e15..4e097c9 100644 --- a/test/assert_msg_test2.cpp +++ b/test/assert_msg_test2.cpp @@ -9,7 +9,7 @@ // #include -#include +#include // default case, !NDEBUG // BOOST_ASSERT_MSG(x) -> assert(x) diff --git a/test/assert_test2.cpp b/test/assert_test2.cpp index 9879ecb..2e36661 100644 --- a/test/assert_test2.cpp +++ b/test/assert_test2.cpp @@ -9,7 +9,7 @@ // #include -#include +#include // default case, !NDEBUG // BOOST_ASSERT(x) -> assert(x) From b89760a0985c743f6bea34310f1270fa5ecb0489 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 26 Feb 2026 12:17:25 +0100 Subject: [PATCH 12/21] Guard assert and current_function --- include/boost/assert.hpp | 10 ++++++++++ include/boost/current_function.hpp | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/include/boost/assert.hpp b/include/boost/assert.hpp index 48c9bcc..f997155 100644 --- a/include/boost/assert.hpp +++ b/include/boost/assert.hpp @@ -29,6 +29,14 @@ // BOOST_ASSERT, BOOST_ASSERT_MSG, BOOST_ASSERT_IS_VOID // +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_ASSERT) +# error "Please #include in your module global fragment" +#endif + +// Don't include the file again in module purviews +#ifndef BOOST_IN_MODULE_PURVIEW + #undef BOOST_ASSERT #undef BOOST_ASSERT_MSG #undef BOOST_ASSERT_IS_VOID @@ -88,4 +96,6 @@ namespace boost # define BOOST_VERIFY(expr) BOOST_ASSERT(expr) # define BOOST_VERIFY_MSG(expr, msg) BOOST_ASSERT_MSG(expr,msg) +#endif // BOOST_IN_MODULE_PURVIEW + #endif diff --git a/include/boost/current_function.hpp b/include/boost/current_function.hpp index 731d1b1..7ea8b42 100644 --- a/include/boost/current_function.hpp +++ b/include/boost/current_function.hpp @@ -1,3 +1,8 @@ +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_CURRENT_FUNCTION_HPP_INCLUDED) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED #define BOOST_CURRENT_FUNCTION_HPP_INCLUDED From aacdf31a33eb81865119815bc8be8437dde90f65 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 26 Feb 2026 12:18:44 +0100 Subject: [PATCH 13/21] Restore source_location --- include/boost/assert/current_location.hpp | 61 ---------------- include/boost/assert/source_location.hpp | 85 +++++++++++++++-------- 2 files changed, 57 insertions(+), 89 deletions(-) delete mode 100644 include/boost/assert/current_location.hpp diff --git a/include/boost/assert/current_location.hpp b/include/boost/assert/current_location.hpp deleted file mode 100644 index 7e85544..0000000 --- a/include/boost/assert/current_location.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef BOOST_ASSERT_CURRENT_LOCATION_HPP_INCLUDED -#define BOOST_ASSERT_CURRENT_LOCATION_HPP_INCLUDED - - -#include - -#if defined(BOOST_DISABLE_CURRENT_LOCATION) - -# define BOOST_CURRENT_LOCATION ::boost::source_location() - -#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1935 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCSIG(), __builtin_COLUMN()) - -#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 - -// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce -// the correct result under 19.31, so prefer the built-ins -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) - -#elif defined(BOOST_MSVC) - -// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before - -# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x) -# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10) - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "") - -#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__) - -// Under nvcc, __builtin_source_location is not constexpr -// https://github.com/boostorg/assert/issues/32 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current()) - -#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) - -#elif defined(BOOST_GCC) && BOOST_GCC >= 80000 - -// The built-ins are available in 4.8+, but are not constant expressions until 7 -// In addition, reproducible builds require -ffile-prefix-map, which is GCC 8 -// https://github.com/boostorg/assert/issues/38 - -# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION()) - -#elif defined(BOOST_GCC) && BOOST_GCC >= 50000 - -// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#else - -// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is -# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "") - -#endif - -#endif \ No newline at end of file diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index a117519..3c2d60e 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -7,41 +7,24 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt -#if defined(BOOST_USE_MODULES) && !defined(BOOST_ASSERT_INTERFACE_UNIT) - -#ifndef BOOST_ASSERT_SKIP_IMPORT -import boost.assert; -#endif - -#else - -#ifndef BOOST_USE_MODULES #include #include -#endif -#include -#include -#include +#include +#include +#include #if !defined(BOOST_NO_IOSTREAM) -#include +#include #endif #if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L -# include -#endif - -// BOOST_ASSERT_MODULE_EXPORT -#ifdef BOOST_USE_MODULES -# define BOOST_ASSERT_MODULE_EXPORT export -#else -# define BOOST_ASSERT_MODULE_EXPORT +# include #endif namespace boost { -BOOST_ASSERT_MODULE_EXPORT struct source_location +struct source_location { private: @@ -154,7 +137,6 @@ BOOST_ASSERT_MODULE_EXPORT struct source_location #if !defined(BOOST_NO_IOSTREAM) -BOOST_ASSERT_MODULE_EXPORT template std::basic_ostream & operator<<( std::basic_ostream & os, source_location const & loc ) { os << loc.to_string(); @@ -165,11 +147,58 @@ template std::basic_ostream & operator<<( std::basic_ost } // namespace boost -#endif // Modules compatibility header +#if defined(BOOST_DISABLE_CURRENT_LOCATION) + +# define BOOST_CURRENT_LOCATION ::boost::source_location() + +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1935 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCSIG(), __builtin_COLUMN()) + +#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926 + +// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce +// the correct result under 19.31, so prefer the built-ins +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) + +#elif defined(BOOST_MSVC) + +// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before + +# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x) +# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10) + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "") + +#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L && !defined(__NVCC__) + +// Under nvcc, __builtin_source_location is not constexpr +// https://github.com/boostorg/assert/issues/32 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current()) + +#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) + +#elif defined(BOOST_GCC) && BOOST_GCC >= 80000 + +// The built-ins are available in 4.8+, but are not constant expressions until 7 +// In addition, reproducible builds require -ffile-prefix-map, which is GCC 8 +// https://github.com/boostorg/assert/issues/38 + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION()) + +#elif defined(BOOST_GCC) && BOOST_GCC >= 50000 + +// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__) + +#else + +// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "") -// Not safe to include in the interface unit because of includes, and not needed -#if !defined(BOOST_ASSERT_INTERFACE_UNIT) -#include #endif #endif // #ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED From f41d99927d0564e952642021589d140821f7de88 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 26 Feb 2026 12:20:14 +0100 Subject: [PATCH 14/21] Make source_location purview safe --- include/boost/assert/source_location.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index 3c2d60e..b83a66d 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -1,3 +1,8 @@ +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED #define BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED @@ -9,16 +14,16 @@ #include #include -#include -#include -#include +#include +#include +#include #if !defined(BOOST_NO_IOSTREAM) -#include +#include #endif #if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L -# include +# include #endif namespace boost From 09389399b0f6439c5c95fe1f1cf562f18064207a Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 26 Feb 2026 12:20:48 +0100 Subject: [PATCH 15/21] switch to headers --- CMakeLists.txt | 21 ++++----------------- modules/boost_assert.cppm | 22 ---------------------- 2 files changed, 4 insertions(+), 39 deletions(-) delete mode 100644 modules/boost_assert.cppm diff --git a/CMakeLists.txt b/CMakeLists.txt index 91bba7b..5b33422 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,26 +7,13 @@ cmake_minimum_required(VERSION 3.5...3.31) project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +add_library(boost_assert INTERFACE) +add_library(Boost::assert ALIAS boost_assert) -if (BOOST_USE_MODULES) - add_library(boost_assert STATIC) - target_sources(boost_assert PUBLIC FILE_SET CXX_MODULES BASE_DIRS modules FILES modules/boost_assert.cppm) - set(__scope PUBLIC) - - # Enable and propagate C++23, import std, and the modules macro - target_compile_features(boost_assert PUBLIC cxx_std_23) - set_target_properties(boost_assert PROPERTIES CXX_MODULE_STD 1) - target_compile_definitions(boost_assert PUBLIC BOOST_USE_MODULES) -else() - add_library(boost_assert INTERFACE) - set(__scope INTERFACE) -endif() - +target_include_directories(boost_assert INTERFACE include) -add_library(Boost::assert ALIAS boost_assert) -target_include_directories(boost_assert ${__scope} include) target_link_libraries(boost_assert - ${__scope} + INTERFACE Boost::config ) diff --git a/modules/boost_assert.cppm b/modules/boost_assert.cppm deleted file mode 100644 index 9d5b78a..0000000 --- a/modules/boost_assert.cppm +++ /dev/null @@ -1,22 +0,0 @@ -module; - -#include -#include - -export module boost.assert; - -import std; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" -#endif - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 5244) -#endif - -#define BOOST_ASSERT_INTERFACE_UNIT -#define BOOST_CONFIG_SKIP_IMPORT_STD -#include From 1128d2f9674ef0143602a675b14eb563fdb8e75d Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 26 Feb 2026 20:17:57 +0100 Subject: [PATCH 16/21] compile definitions for BOOST_USE_MODULES --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b33422..d96c594 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,10 @@ target_link_libraries(boost_assert Boost::config ) +if (BOOST_USE_MODULES) + target_compile_definitions(boost_assert INTERFACE BOOST_USE_MODULES) +endif() + # Add headers and .natvis to project, for better IDE integration if(NOT CMAKE_VERSION VERSION_LESS 3.19) From 796c8a49d83927e1e06925b3674ddb1df7b057c6 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 5 Mar 2026 14:43:21 +0100 Subject: [PATCH 17/21] CI --- .github/workflows/ci.yml | 380 ++++++++++++++++++++++++++++++ tools/install-cmake.sh | 15 ++ tools/setup_boost_with_modules.py | 28 +++ 3 files changed, 423 insertions(+) create mode 100755 tools/install-cmake.sh create mode 100644 tools/setup_boost_with_modules.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1294803..c63f775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -644,3 +644,383 @@ jobs: run: | cd ../boost-root/__build__ ctest --output-on-failure --no-tests=error -C Release + + posix-cmake-subdir-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake subdir modules ${{ matrix.name }} + + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Use library with add_subdirectory + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBUILD_TESTING=ON \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-install-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake install modules ${{ matrix.name }} + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DCMAKE_INSTALL_PREFIX=~/.local \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + + - name: Install + run: | + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DCMAKE_INSTALL_PREFIX=~/.local \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-test-modules: + strategy: + fail-fast: false + matrix: + include: + - name: "clang-21 Debug" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Debug" + - name: "clang-21 Release" + packages: "clang-21 libc++-21-dev" + cmake-args: "-DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -DCMAKE_CXX_STDLIB_MODULES_JSON=/usr/lib/llvm-21/lib/libc++.modules.json -DCMAKE_BUILD_TYPE=Release" + - name: "gcc-15 Debug" + packages: "g++-15" + cmake-args: "-DCMAKE_CXX_COMPILER=g++-15 -DCMAKE_BUILD_TYPE=Debug" + + name: CMake test modules ${{ matrix.name }} + + runs-on: ubuntu-latest + container: ubuntu:26.04 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: | + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install -y --no-install-recommends wget ninja-build git ca-certificates python3 python-is-python3 ${{ matrix.packages }} + ./tools/install-cmake.sh + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DBUILD_TESTING=ON \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + ${{ matrix.cmake-args }} \ + .. + + - name: Build tests + run: | + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error + + windows-cmake-subdir-modules: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Use library with add_subdirectory + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + cmake --build . + ctest --output-on-failure --no-tests=error + + windows-cmake-install-modules: + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + + - name: Install + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Use the installed library + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -G Ninja .. + cmake --build . + ctest --output-on-failure --no-tests=error + + windows-cmake-test-modules: + strategy: + fail-fast: false + matrix: + include: + - cmake-build-type: Debug + - cmake-build-type: Release + + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v4 + + - name: Install packages + run: choco install --no-progress ninja + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON -DBOOST_USE_MODULES=1 -DCMAKE_CXX_STANDARD=23 -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=0e5b6991-d74f-4b3d-a41c-cf096e0b2508 -DCMAKE_BUILD_TYPE=${{matrix.cmake-build-type}} -G Ninja .. + + - name: Build tests + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + shell: cmd + run: | + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error diff --git a/tools/install-cmake.sh b/tools/install-cmake.sh new file mode 100755 index 0000000..d2fd0bb --- /dev/null +++ b/tools/install-cmake.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# +# Copyright (c) 2026 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) +# +# 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) +# + +set -e + +wget https://github.com/Kitware/CMake/releases/download/v4.2.3/cmake-4.2.3-linux-x86_64.tar.gz +tar -xf cmake-4.2.3-linux-x86_64.tar.gz +mv cmake-4.2.3-linux-x86_64 /opt/cmake +update-alternatives --install /usr/bin/cmake cmake /opt/cmake/bin/cmake 100 +update-alternatives --install /usr/bin/ctest ctest /opt/cmake/bin/ctest 100 diff --git a/tools/setup_boost_with_modules.py b/tools/setup_boost_with_modules.py new file mode 100644 index 0000000..13b840d --- /dev/null +++ b/tools/setup_boost_with_modules.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 + +# This is a temporary workaround to make CIs use the +# "Boost with C++20 modules" proposal, instead of the regular develop branch +# Call it instead of depinst + +from subprocess import run +import os + +def main(): + + submodules = [ + ('tools/cmake', 'https://github.com/anarthal/boost-cmake'), + ('libs/assert', 'https://github.com/anarthal/assert'), + ('libs/core', 'https://github.com/anarthal/core'), + ('libs/config', 'https://github.com/anarthal/config'), + ] + + for submodule, url in submodules: + os.chdir(submodule) + run(['git', 'remote', 'add', 'modules', url]) + run(['git', 'fetch', '--depth', '1', 'modules', 'feature/cxx20-modules']) + run(['git', 'checkout', 'modules/feature/cxx20-modules']) + os.chdir('../..') + + +if __name__ == '__main__': + main() From f2303992a5aca7677bd99b55c816194a64eb151c Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 5 Mar 2026 14:44:00 +0100 Subject: [PATCH 18/21] Trigger CI From 16d64720ebbbda6a07e6419c2aaf8bf92401f133 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 5 Mar 2026 14:54:57 +0100 Subject: [PATCH 19/21] checkout branches in all jobs --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c63f775..ffe90a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -251,6 +251,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python3 libs/assert/tools/setup_boost_with_modules.py # Temporary ./bootstrap.sh ./b2 -d0 headers @@ -306,6 +307,7 @@ jobs: xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary cmd /c bootstrap b2 -d0 headers @@ -351,6 +353,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Use library with add_subdirectory run: | @@ -396,6 +399,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -451,6 +455,7 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -499,6 +504,7 @@ jobs: xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Use library with add_subdirectory (Debug) shell: cmd @@ -547,6 +553,7 @@ jobs: xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Configure shell: cmd @@ -613,6 +620,7 @@ jobs: xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python libs/assert/tools/setup_boost_with_modules.py # Temporary - name: Configure shell: cmd From c416d3a148c4827d066ddb4ac81755333ca25758 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 5 Mar 2026 15:22:54 +0100 Subject: [PATCH 20/21] remove ourselves --- tools/setup_boost_with_modules.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/setup_boost_with_modules.py b/tools/setup_boost_with_modules.py index 13b840d..8f37e7f 100644 --- a/tools/setup_boost_with_modules.py +++ b/tools/setup_boost_with_modules.py @@ -11,7 +11,6 @@ def main(): submodules = [ ('tools/cmake', 'https://github.com/anarthal/boost-cmake'), - ('libs/assert', 'https://github.com/anarthal/assert'), ('libs/core', 'https://github.com/anarthal/core'), ('libs/config', 'https://github.com/anarthal/config'), ] From d6a56a90a7d884366a389a91bc461453f859f2a2 Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Thu, 5 Mar 2026 16:56:24 +0100 Subject: [PATCH 21/21] checkout throw_exception --- tools/setup_boost_with_modules.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/setup_boost_with_modules.py b/tools/setup_boost_with_modules.py index 8f37e7f..8a43d61 100644 --- a/tools/setup_boost_with_modules.py +++ b/tools/setup_boost_with_modules.py @@ -12,6 +12,7 @@ def main(): submodules = [ ('tools/cmake', 'https://github.com/anarthal/boost-cmake'), ('libs/core', 'https://github.com/anarthal/core'), + ('libs/throw_exception','https://github.com/anarthal/throw_exception'), ('libs/config', 'https://github.com/anarthal/config'), ]