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 diff --git a/CMakeLists.txt b/CMakeLists.txt index dbc4f15..d11d834 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,12 @@ # Generated by `boostdep --cmake sort` -# Copyright 2020 Peter Dimov +# 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 -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 +22,25 @@ target_link_libraries(boost_sort Boost::type_traits ) +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + + 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") - 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() - # 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() 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()