diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c5f664..18315ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -240,6 +240,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/throw_exception/tools/setup_boost_with_modules.py # Temporary ./bootstrap.sh ./b2 -d0 headers @@ -295,6 +296,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/throw_exception/tools/setup_boost_with_modules.py # Temporary cmd /c bootstrap b2 -d0 headers @@ -343,6 +345,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Use library with add_subdirectory run: | @@ -391,6 +394,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -449,6 +453,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Configure run: | @@ -497,6 +502,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Use library with add_subdirectory (Debug) shell: cmd @@ -545,6 +551,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Configure shell: cmd @@ -611,6 +618,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/throw_exception/tools/setup_boost_with_modules.py # Temporary - name: Configure shell: cmd @@ -642,3 +650,350 @@ jobs: run: | cd ../boost-root/__build__ ctest --output-on-failure --no-tests=error -C Release + + posix-cmake-subdir-modules: + 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 g++-15 + ./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/throw_exception/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 \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_CXX_MODULE_STD=ON \ + -DCMAKE_CXX_SCAN_FOR_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + -DCMAKE_CXX_COMPILER=g++-15 \ + .. + cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-install-modules: + 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 g++-15 + ./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/throw_exception/tools/setup_boost_with_modules.py # Temporary + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake \ + -G Ninja \ + -DBOOST_INCLUDE_LIBRARIES=$LIBRARY \ + -DCMAKE_INSTALL_PREFIX=~/.local \ + -DBOOST_USE_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + -DCMAKE_CXX_COMPILER=g++-15 \ + .. + + - 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_CXX_MODULE_STD=ON \ + -DCMAKE_CXX_SCAN_FOR_MODULES=ON \ + -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=d0edc3af-4c50-42ea-a356-e2862fe7a444 \ + -DCMAKE_CXX_COMPILER=g++-15 \ + .. + 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/throw_exception/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/throw_exception/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_MODULE_STD=ON -DCMAKE_CXX_SCAN_FOR_MODULES=ON -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/throw_exception/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_MODULE_STD=ON -DCMAKE_CXX_SCAN_FOR_MODULES=ON -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/throw_exception/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/CMakeLists.txt b/CMakeLists.txt index a994885..9ccea77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # 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 -cmake_minimum_required(VERSION 3.5...3.16) +cmake_minimum_required(VERSION 3.5...3.31) project(boost_throw_exception VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_throw_exception INTERFACE) @@ -16,6 +16,13 @@ target_link_libraries(boost_throw_exception Boost::config ) +if (BOOST_USE_MODULES) + # This library exports only headers even with BOOST_USE_MODULES, + # but consuming it requires 'import std' and defining BOOST_USE_MODULES + target_compile_features(boost_throw_exception INTERFACE cxx_std_23) + target_compile_definitions(boost_throw_exception INTERFACE BOOST_USE_MODULES) +endif() + if(BUILD_TESTING) add_subdirectory(test) diff --git a/appveyor.yml b/appveyor.yml index e325b0e..0384a4c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -62,6 +62,7 @@ install: - git submodule update --init tools/boostdep - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\throw_exception\ - python tools/boostdep/depinst/depinst.py throw_exception + - python libs/throw_exception/tools/setup_boost_with_modules.py # Temporary - cmd /c bootstrap - b2 -d0 headers diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index e6d340c..fb3c08a 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -8,10 +8,10 @@ #include #include -#include +#include #ifdef BOOST_EXCEPTION_MINI_BOOST -#include +#include namespace boost { namespace exception_detail { using std::shared_ptr; } } #else namespace boost { template class shared_ptr; } diff --git a/include/boost/throw_exception.hpp b/include/boost/throw_exception.hpp index 7c7fcbd..1ff9dfd 100644 --- a/include/boost/throw_exception.hpp +++ b/include/boost/throw_exception.hpp @@ -1,3 +1,8 @@ +// Make the header safe to include from libraries supporting modules +#if defined(BOOST_IN_MODULE_PURVIEW) && !defined(BOOST_THROW_EXCEPTION_HPP_INCLUDED) +# error "Please #include in your module global fragment" +#endif + #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED #define BOOST_THROW_EXCEPTION_HPP_INCLUDED @@ -22,11 +27,11 @@ #include #include #include -#include -#include -#include +#include +#include +#include #if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) -#include +#include #endif #if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) ) @@ -103,10 +108,11 @@ template struct BOOST_SYMBOL_VISIBLE wrapexcept: { copy_from( &e ); - set_info( *this, throw_file( loc.file_name() ) ); - set_info( *this, throw_line( static_cast( loc.line() ) ) ); - set_info( *this, throw_function( loc.function_name() ) ); - set_info( *this, throw_column( static_cast( loc.column() ) ) ); + // RP TODO: gcc fails to find these by ADL when using modules for some reason + exception_detail::set_info( *this, throw_file( loc.file_name() ) ); + exception_detail::set_info( *this, throw_line( static_cast( loc.line() ) ) ); + exception_detail::set_info( *this, throw_function( loc.function_name() ) ); + exception_detail::set_info( *this, throw_column( static_cast( loc.column() ) ) ); } virtual boost::exception_detail::clone_base const * clone() const BOOST_OVERRIDE diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 486b61f..4f1ed59 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::throw_exception Boost::core Boost::exception) endif() diff --git a/test/cmake_install_test/main.cpp b/test/cmake_install_test/main.cpp index 771931e..5b6b131 100644 --- a/test/cmake_install_test/main.cpp +++ b/test/cmake_install_test/main.cpp @@ -3,7 +3,7 @@ // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt #include -#include +#include int main() { diff --git a/test/cmake_subdir_test/main.cpp b/test/cmake_subdir_test/main.cpp index 771931e..5b6b131 100644 --- a/test/cmake_subdir_test/main.cpp +++ b/test/cmake_subdir_test/main.cpp @@ -3,7 +3,7 @@ // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt #include -#include +#include int main() { diff --git a/test/lib1_throw.hpp b/test/lib1_throw.hpp index f3d169b..a5f5edc 100644 --- a/test/lib1_throw.hpp +++ b/test/lib1_throw.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include +#include #if defined(LIB1_DYN_LINK) # if defined(LIB1_SOURCE) diff --git a/test/lib2_throw.hpp b/test/lib2_throw.hpp index 59e8dc2..367b3b8 100644 --- a/test/lib2_throw.hpp +++ b/test/lib2_throw.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include +#include #if defined(LIB2_DYN_LINK) # if defined(LIB2_SOURCE) diff --git a/test/lib3_throw.hpp b/test/lib3_throw.hpp index da280ab..274b4cb 100644 --- a/test/lib3_throw.hpp +++ b/test/lib3_throw.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include +#include #if defined(LIB3_DYN_LINK) # if defined(LIB3_SOURCE) diff --git a/test/lib4_throw.hpp b/test/lib4_throw.hpp index 67bc03f..ea099e1 100644 --- a/test/lib4_throw.hpp +++ b/test/lib4_throw.hpp @@ -9,7 +9,7 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include +#include #if defined(LIB4_DYN_LINK) # if defined(LIB4_SOURCE) diff --git a/test/make_exception_ptr_nx_test.cpp b/test/make_exception_ptr_nx_test.cpp index 72d2f7b..c56d478 100644 --- a/test/make_exception_ptr_nx_test.cpp +++ b/test/make_exception_ptr_nx_test.cpp @@ -2,6 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code # pragma warning(disable: 4577) // noexcept used without /EHsc @@ -27,3 +38,5 @@ void throw_exception( std::exception const & ) } } // namespace boost + +#endif diff --git a/test/make_exception_ptr_nx_test2.cpp b/test/make_exception_ptr_nx_test2.cpp index 4ec8626..68ae8c9 100644 --- a/test/make_exception_ptr_nx_test2.cpp +++ b/test/make_exception_ptr_nx_test2.cpp @@ -2,6 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code # pragma warning(disable: 4577) // noexcept used without /EHsc @@ -29,3 +40,5 @@ void throw_exception( std::exception const & ) } } // namespace boost + +#endif diff --git a/test/make_exception_ptr_test.cpp b/test/make_exception_ptr_test.cpp index f152192..010fee8 100644 --- a/test/make_exception_ptr_test.cpp +++ b/test/make_exception_ptr_test.cpp @@ -2,6 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code #endif @@ -16,3 +27,5 @@ int main() BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception ); return boost::report_errors(); } + +#endif diff --git a/test/make_exception_ptr_test2.cpp b/test/make_exception_ptr_test2.cpp index 86cf5a4..ffc6254 100644 --- a/test/make_exception_ptr_test2.cpp +++ b/test/make_exception_ptr_test2.cpp @@ -2,6 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code #endif @@ -18,3 +29,5 @@ int main() BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception ); return boost::report_errors(); } + +#endif diff --git a/test/throw_exception_no_both_test.cpp b/test/throw_exception_no_both_test.cpp index e87695a..e67675c 100644 --- a/test/throw_exception_no_both_test.cpp +++ b/test/throw_exception_no_both_test.cpp @@ -7,7 +7,7 @@ #define BOOST_EXCEPTION_DISABLE #include -#include +#include #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code diff --git a/test/throw_exception_no_exceptions_test.cpp b/test/throw_exception_no_exceptions_test.cpp index 8bfb95e..baa2df4 100644 --- a/test/throw_exception_no_exceptions_test.cpp +++ b/test/throw_exception_no_exceptions_test.cpp @@ -6,7 +6,7 @@ #define BOOST_NO_EXCEPTIONS #include -#include +#include #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code diff --git a/test/throw_exception_nx_test.cpp b/test/throw_exception_nx_test.cpp index 589f7db..8146478 100644 --- a/test/throw_exception_nx_test.cpp +++ b/test/throw_exception_nx_test.cpp @@ -9,7 +9,7 @@ #endif #include -#include +#include class my_exception: public std::exception {}; diff --git a/test/throw_exception_nx_test2.cpp b/test/throw_exception_nx_test2.cpp index 438b2e4..92cd262 100644 --- a/test/throw_exception_nx_test2.cpp +++ b/test/throw_exception_nx_test2.cpp @@ -9,8 +9,8 @@ #endif #include -#include -#include +#include +#include class my_exception: public std::exception {}; diff --git a/test/throw_exception_test3.cpp b/test/throw_exception_test3.cpp index 3e80773..39adc17 100644 --- a/test/throw_exception_test3.cpp +++ b/test/throw_exception_test3.cpp @@ -5,6 +5,17 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code #endif @@ -109,3 +120,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/throw_exception_test4.cpp b/test/throw_exception_test4.cpp index cc36c2f..31d2cf6 100644 --- a/test/throw_exception_test4.cpp +++ b/test/throw_exception_test4.cpp @@ -5,10 +5,21 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #include #include #include -#include +#include class my_exception: public std::exception { @@ -62,7 +73,7 @@ int main() int const * line = boost::get_error_info( x ); BOOST_TEST( line != 0 ); - BOOST_TEST_EQ( *line, 50 ); + BOOST_TEST_EQ( *line, 61 ); } { @@ -90,7 +101,7 @@ int main() int const * line = boost::get_error_info( x ); BOOST_TEST( line != 0 ); - BOOST_TEST_EQ( *line, 78 ); + BOOST_TEST_EQ( *line, 89 ); } { @@ -118,7 +129,7 @@ int main() int const * line = boost::get_error_info( x ); BOOST_TEST( line != 0 ); - BOOST_TEST_EQ( *line, 106 ); + BOOST_TEST_EQ( *line, 117 ); } { @@ -131,3 +142,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/throw_exception_test5.cpp b/test/throw_exception_test5.cpp index 32970cf..47c733c 100644 --- a/test/throw_exception_test5.cpp +++ b/test/throw_exception_test5.cpp @@ -5,6 +5,17 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(__clang__) # pragma clang diagnostic ignored "-Wunknown-pragmas" # pragma clang diagnostic ignored "-Wunknown-warning-option" @@ -16,7 +27,7 @@ #include #include #include -#include +#include typedef boost::error_info error_code; typedef boost::error_info error_string; @@ -117,3 +128,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/throw_from_library_test.cpp b/test/throw_from_library_test.cpp index a3dc073..ba9ced6 100644 --- a/test/throw_from_library_test.cpp +++ b/test/throw_from_library_test.cpp @@ -5,6 +5,17 @@ // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt +#ifdef BOOST_USE_MODULES + +import std.compat; + +int main() +{ + printf("This test depends on Boost.Exception and can't be run with C++20 modules yet\n"); +} + +#else + #if defined(_MSC_VER) # pragma warning(disable: 4702) // unreachable code #endif @@ -110,3 +121,5 @@ int main() return boost::report_errors(); } + +#endif diff --git a/test/throw_with_location_nx_test.cpp b/test/throw_with_location_nx_test.cpp index e93e600..c436e7c 100644 --- a/test/throw_with_location_nx_test.cpp +++ b/test/throw_with_location_nx_test.cpp @@ -9,7 +9,7 @@ #endif #include -#include +#include class my_exception: public std::exception {}; 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..b1d1679 --- /dev/null +++ b/tools/setup_boost_with_modules.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# 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 check_call +import os + +def main(): + + submodules = [ + ('tools/cmake', 'https://github.com/anarthal/boost-cmake'), + ('libs/core', 'https://github.com/anarthal/core'), + ('libs/assert', 'https://github.com/anarthal/assert'), + ('libs/config', 'https://github.com/anarthal/config'), + ] + + for submodule, url in submodules: + os.chdir(submodule) + check_call(['git', 'remote', 'add', 'modules', url]) + check_call(['git', 'fetch', '--depth', '1', 'modules', 'feature/cxx20-modules']) + check_call(['git', 'checkout', 'modules/feature/cxx20-modules']) + os.chdir('../..') + + +if __name__ == '__main__': + main()