From f68e4df7e62fb4f16d0d9eb014c63d3c2ad6f1f1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Oct 2025 13:12:48 +0200 Subject: [PATCH 1/5] Add posix-standalone-cmake-test to GHA --- .github/workflows/ci.yml | 72 +++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47d4c37..4e864ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,10 +78,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install packages - if: matrix.install - run: sudo apt install ${{matrix.install}} - - name: Setup Boost run: | echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY @@ -123,10 +119,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install packages - if: matrix.install - run: sudo apt install ${{matrix.install}} - - name: Setup Boost run: | echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY @@ -178,10 +170,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install packages - if: matrix.install - run: sudo apt install ${{matrix.install}} - - name: Setup Boost run: | echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY @@ -217,3 +205,63 @@ jobs: run: | cd ../boost-root/__build__ ctest --output-on-failure --no-tests=error + + posix-standalone-cmake-test: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + - os: macos-latest + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v4 + + - 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 --git_args "--jobs 3" $LIBRARY + + - name: Configure Boost + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + + - name: Install Boost + run: | + cd ../boost-root/__build__ + cmake --build . --target install + + - name: Configure + run: | + mkdir __build__ + cd __build__ + cmake -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=~/.local .. + + - name: Build tests + run: | + cd __build__ + cmake --build . --target tests + + - name: Run tests + run: | + cd __build__ + ctest --output-on-failure --no-tests=error From b3425e966e7afe67c3f6beac80f111eba40a8c61 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Oct 2025 13:43:36 +0200 Subject: [PATCH 2/5] Regenerate CMakeLists.txt using `boostdep --cmake sort` --- CMakeLists.txt | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbc4f15..01bd2c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,11 @@ # Generated by `boostdep --cmake sort` -# Copyright 2020 Peter Dimov -# Copyright 2025 Nigel Stewart +# Copyright 2020, 2021 Peter Dimov # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt -message(STATUS "Using cmake version ${CMAKE_VERSION}") +cmake_minimum_required(VERSION 3.8...3.31) -cmake_minimum_required(VERSION 3.10...3.16) - -if(BOOST_SUPERPROJECT_VERSION) - project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) -else() - project(boost_sort LANGUAGES CXX) -endif() - -# Test coverage in stand-alone mode requires boost dependencies -if(BUILD_TESTING AND NOT BOOST_SUPERPROJECT_VERSION) - set(Boost_DEBUG ON) - find_package(Boost 1.85 REQUIRED COMPONENTS core range included_test_exec_monitor) -endif() +project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_sort INTERFACE) add_library(Boost::sort ALIAS boost_sort) @@ -34,17 +21,8 @@ target_link_libraries(boost_sort Boost::type_traits ) -# Testing if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") - if(NOT BOOST_SUPERPROJECT_VERSION) - include(CTest) - enable_testing() - add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) - add_dependencies(check tests) - endif() + add_subdirectory(test) - # Follow the Boost convention: don't build test targets by default, - # and only when explicitly requested by building target tests - add_subdirectory(test EXCLUDE_FROM_ALL) endif() From d289104488fcc6e71a7eebb3c97f0aeaf1703504 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Oct 2025 13:45:12 +0200 Subject: [PATCH 3/5] Bring back standalone functionality, but only when the library is the root project --- CMakeLists.txt | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01bd2c7..d11d834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ # Generated by `boostdep --cmake sort` # Copyright 2020, 2021 Peter Dimov +# Copyright 2025 Nigel Stewart # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt @@ -21,8 +22,25 @@ target_link_libraries(boost_sort Boost::type_traits ) -if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - add_subdirectory(test) + message(STATUS "Using CMake version ${CMAKE_VERSION}") + + set(Boost_DEBUG ON) + find_package(Boost 1.85 CONFIG REQUIRED COMPONENTS core range included_test_exec_monitor) + + include(CTest) + + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) + add_dependencies(check tests) + +endif() + +# Testing +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + # Follow the Boost convention: don't build test targets by default, + # and only when explicitly requested by building target tests + add_subdirectory(test EXCLUDE_FROM_ALL) endif() From c39164a8c54306504cabac88a85c565192db2b36 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Oct 2025 14:12:16 +0200 Subject: [PATCH 4/5] Replace CMAKE_CXX_STANDARD override with target_compile_features --- test/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ad6895a..bb9a190 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,3 @@ -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # warning level 4 add_compile_options(/W4) @@ -21,11 +17,13 @@ endif() set(PREFIX "boost_sort_") set(LINK_LIBRARIES Boost::sort Boost::included_test_exec_monitor) +set(COMPILE_FEATURES cxx_std_11) function(boost_sort_add_test name source) set(pname "${PREFIX}${name}") add_executable(${pname} ${source}) - target_link_libraries(${pname} ${LINK_LIBRARIES}) + target_link_libraries(${pname} PRIVATE ${LINK_LIBRARIES}) + target_compile_features(${pname} PRIVATE ${COMPILE_FEATURES}) add_test(NAME ${pname} COMMAND ${pname}) add_dependencies(tests ${pname}) endfunction() From 5ccd8dc8ae0fdf6efcc6c5d79ad924b9ea32bcf8 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Fri, 31 Oct 2025 20:54:04 +1000 Subject: [PATCH 5/5] CMake 3.8 does not work stand-alone, come forward to non-deprecated 3.10 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d11d834..85d07ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required(VERSION 3.8...3.31) +cmake_minimum_required(VERSION 3.10...3.31) project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)