diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da44d53c..0dc8923f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,9 @@ jobs: fail-fast: false matrix: include: + - toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below + cxxstd: "03,11,14,17,20" + os: ubuntu-24.04 - toolset: gcc-12 cxxstd: "03,11,14,17,2a" os: ubuntu-22.04 @@ -59,9 +62,20 @@ jobs: cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY ./bootstrap.sh - ./b2 -d0 headers ./b2 -j4 variant=debug tools/inspect + - name: Run CMake tests + if: ${{matrix.toolset == 'gcc-14'}} + run: | + cd ../boost-root/ + mkdir __build + cd __build + cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 .. + cmake --build . --target tests + ctest --output-on-failure --no-tests=error + cd .. + rm -rf __build + - name: Run tests run: | cd ../boost-root @@ -101,14 +115,14 @@ jobs: fail-fast: false matrix: include: - - toolset: msvc-14.2 + - toolset: msvc-14.3 cxxstd: "14,17,latest" addrmd: 32,64 - os: windows-2019 + os: windows-2025 - toolset: gcc cxxstd: "03,11,14,17,2a" addrmd: 64 - os: windows-2019 + os: windows-2025 runs-on: ${{matrix.os}} @@ -135,7 +149,21 @@ jobs: git submodule update --init tools/boostdep python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY% cmd /c bootstrap - b2 -d0 headers + + - name: Run CMake tests + if: ${{matrix.toolset == 'msvc-14.3'}} + shell: cmd + run: | + choco install --no-progress ninja + call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64 + cd ../boost-root/ + mkdir __build + cd __build + cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion .. + cmake --build . --target tests --config Debug + ctest --output-on-failure --no-tests=error -C Debug + cd .. + rm -rf __build - name: Run tests shell: cmd diff --git a/CMakeLists.txt b/CMakeLists.txt index dfde0f6a..d8da837f 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 https://www.boost.org/LICENSE_1_0.txt -cmake_minimum_required( VERSION 3.5...3.20 ) +cmake_minimum_required( VERSION 3.5...4.20 ) project( boost_conversion VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX ) add_library( boost_conversion INTERFACE ) @@ -14,6 +14,9 @@ target_link_libraries( boost_conversion INTERFACE Boost::assert Boost::config - Boost::smart_ptr Boost::throw_exception ) + +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/build.jam b/build.jam index a266ab2c..6c21796a 100644 --- a/build.jam +++ b/build.jam @@ -8,7 +8,6 @@ require-b2 5.2 ; constant boost_dependencies : /boost/assert//boost_assert /boost/config//boost_config - /boost/smart_ptr//boost_smart_ptr /boost/throw_exception//boost_throw_exception ; project /boost/conversion diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..7391415c --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (c) 2016-2025 Antony Polukhin +# 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 + +include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(NOT HAVE_BOOST_TEST) + return() +endif() + +set(BOOST_TEST_LINK_LIBRARIES Boost::conversion Boost::core) + +boost_test(TYPE run SOURCES cast_test.cpp) +boost_test(TYPE run SOURCES implicit_cast.cpp) +boost_test(TYPE compile-fail SOURCES implicit_cast_fail.cpp) +boost_test(TYPE compile-fail SOURCES implicit_cast_fail2.cpp) +boost_test(TYPE run SOURCES polymorphic_cast_test.cpp LINK_LIBRARIES Boost::smart_ptr) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 3dd61b02..15c2ab88 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,6 +26,6 @@ test-suite conversion : [ run implicit_cast.cpp ] [ compile-fail implicit_cast_fail.cpp ] [ run cast_test.cpp ] - [ run polymorphic_cast_test.cpp ] + [ run polymorphic_cast_test.cpp : : : /boost/smart_ptr//boost_smart_ptr ] [ compile-fail implicit_cast_fail2.cpp ] ; diff --git a/test/implicit_cast.cpp b/test/implicit_cast.cpp index cf4cb940..92f21607 100644 --- a/test/implicit_cast.cpp +++ b/test/implicit_cast.cpp @@ -4,8 +4,9 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include +#include #include + using boost::implicit_cast; using boost::type;