From 5757bfa945df3fd467b56993ee9d370ab2151b9d Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 27 Jun 2025 17:48:00 +0300 Subject: [PATCH 1/3] Test CMake in CI and add initial CMakeLists.txt for tests --- .github/workflows/ci.yml | 14 +++++++++++++- README.md | 4 ++-- test/CMakeLists.txt | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99859e6a..19f845ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: fail-fast: false matrix: include: - - toolset: gcc-14 + - toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below cxxstd: "11,14,17,2a" os: ubuntu-24.04 # UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags! @@ -92,6 +92,18 @@ jobs: ./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=dll -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 diff --git a/README.md b/README.md index de5b9c0a..98ac6049 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Boost.DLL is a part of the [Boost C++ Libraries](https://github.com/boostorg). I Branches | Build | Tests coverage | More info ----------------|-------------- | -------------- |----------- -Develop: | [![CI](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/t6q6yhcabtk5b99l/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/develop) | [![Coverage Status](https://coveralls.io/repos/apolukhin/Boost.DLL/badge.png?branch=develop)](https://coveralls.io/r/apolukhin/Boost.DLL?branch=develop) | [details...](https://www.boost.org/development/tests/develop/developer/dll.html) -Master: | [![CI](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/t6q6yhcabtk5b99l/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/master) | [![Coverage Status](https://coveralls.io/repos/apolukhin/Boost.DLL/badge.png?branch=master)](https://coveralls.io/r/apolukhin/Boost.DLL?branch=master) | [details...](https://www.boost.org/development/tests/master/developer/dll.html) +Develop: | [![CI](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/t6q6yhcabtk5b99l/branch/develop?svg=true)](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/develop) | [![Coverage Status](https://coveralls.io/repos/apolukhin/Boost.DLL/badge.png?branch=develop)](https://coveralls.io/r/apolukhin/Boost.DLL?branch=develop) | [details...](https://regression.boost.io/develop/developer/dll.html) +Master: | [![CI](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/apolukhin/Boost.DLL/actions/workflows/ci.yml) [![Build status](https://ci.appveyor.com/api/projects/status/t6q6yhcabtk5b99l/branch/master?svg=true)](https://ci.appveyor.com/project/apolukhin/boost-dll/branch/master) | [![Coverage Status](https://coveralls.io/repos/apolukhin/Boost.DLL/badge.png?branch=master)](https://coveralls.io/r/apolukhin/Boost.DLL?branch=master) | [details...](https://regression.boost.io/master/developer/dll.html) [Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/boost_dll.html) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..bfb195be --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,13 @@ +# 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 + +if(NOT TARGET tests) + add_custom_target(tests) +endif() + +add_executable(dll_tests_cpp_mangling "cpp_mangling.cpp") +target_link_libraries(dll_tests_cpp_mangling Boost::dll) +add_test(NAME dll_tests_cpp_mangling COMMAND dll_tests_cpp_mangling) +add_dependencies(tests dll_tests_cpp_mangling) + From 2007594b2c85d9f5b2cd6c4c7dc4d2c842b71afd Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 27 Jun 2025 18:18:26 +0300 Subject: [PATCH 2/3] Fix --- CMakeLists.txt | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e5b2ed7..62b1bf3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,16 +10,45 @@ project(boost_dll VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) option(BOOST_DLL_USE_STD_FS "Use std::filesystem instead of Boost.Filesystem" OFF) -add_library(boost_dll INTERFACE) -add_library(Boost::dll ALIAS boost_dll) +add_library(boost_dll_base INTERFACE) +target_include_directories(boost_dll_base INTERFACE include) +target_link_libraries(boost_dll_base + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::predef + Boost::system + Boost::throw_exception + Boost::type_index + Boost::winapi + ${CMAKE_DL_LIBS} +) + + +add_library(boost_dll_std_fs INTERFACE) +target_link_libraries(boost_dll_std_fs + INTERFACE + boost_dll_base +) +target_compile_definitions(boost_dll_std_fs INTERFACE BOOST_DLL_USE_STD_FS) +target_compile_features(boost_dll_std_fs INTERFACE cxx_std_17) + +add_library(boost_dll_boost_fs INTERFACE) +target_link_libraries(boost_dll_boost_fs + INTERFACE + boost_dll_base + Boost::filesystem +) -target_include_directories(boost_dll INTERFACE include) +add_library(boost_dll INTERFACE) target_link_libraries(boost_dll INTERFACE Boost::assert Boost::config Boost::core + Boost::filesystem Boost::predef Boost::system Boost::throw_exception @@ -27,14 +56,14 @@ target_link_libraries(boost_dll Boost::winapi ${CMAKE_DL_LIBS} ) - if(BOOST_DLL_USE_STD_FS) - target_compile_definitions(boost_dll INTERFACE BOOST_DLL_USE_STD_FS) - target_compile_features(boost_dll INTERFACE cxx_std_17) + target_link_libraries(boost_dll INTERFACE boost_dll_std_fs) else() - target_link_libraries(boost_dll INTERFACE Boost::filesystem) + target_link_libraries(boost_dll INTERFACE boost_dll_boost_fs) endif() +add_library(Boost::dll ALIAS boost_dll) + if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) From 25dc02c973f1feebbe5d584db6af4cbee004013b Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Fri, 27 Jun 2025 20:22:47 +0300 Subject: [PATCH 3/3] cleanup --- CMakeLists.txt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62b1bf3c..0a717471 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,19 +43,6 @@ target_link_libraries(boost_dll_boost_fs add_library(boost_dll INTERFACE) -target_link_libraries(boost_dll - INTERFACE - Boost::assert - Boost::config - Boost::core - Boost::filesystem - Boost::predef - Boost::system - Boost::throw_exception - Boost::type_index - Boost::winapi - ${CMAKE_DL_LIBS} -) if(BOOST_DLL_USE_STD_FS) target_link_libraries(boost_dll INTERFACE boost_dll_std_fs) else()