From d66d4318806d9780a5ee4a57eafa450b0abca009 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Mon, 13 Apr 2026 15:22:05 +0000 Subject: [PATCH 01/13] support cmake tests --- test/CMakeLists.txt | 126 +++++++++++++++++++++++++- test/cmake_subdir_test/CMakeLists.txt | 59 ++++++++++++ 2 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 test/cmake_subdir_test/CMakeLists.txt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc49748b..9d24bea3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright Antony Polukhin, 2021-2026 +# Copyright Fedor Osetrov, 2025-2026 # # 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 @@ -7,8 +8,125 @@ 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) +# Test libraries and plugins +add_library(dll_static_plugin STATIC ../example/tutorial4/static_plugin.cpp) +target_link_libraries(dll_static_plugin PRIVATE Boost::dll) + +add_library(dll_static_refcounting_plugin STATIC ../example/tutorial8/refcounting_plugin.cpp) +target_link_libraries(dll_static_refcounting_plugin PRIVATE Boost::dll) + +add_library(dll_test_library SHARED test_library.cpp) +target_link_libraries(dll_test_library PRIVATE Boost::dll Boost::fusion) + +add_library(dll_empty_library SHARED empty_library.cpp) + +add_library(dll_getting_started_library SHARED ../example/getting_started_library.cpp) +target_link_libraries(dll_getting_started_library PRIVATE Boost::dll) + +add_library(dll_my_plugin_sum SHARED ../example/tutorial1/my_plugin_sum.cpp) +target_link_libraries(dll_my_plugin_sum PRIVATE Boost::dll) +set_target_properties(dll_my_plugin_sum + PROPERTIES + OUTPUT_NAME "my_plugin_sum" +) + +add_library(dll_my_plugin_aggregator SHARED ../example/tutorial2/my_plugin_aggregator.cpp) +target_link_libraries(dll_my_plugin_aggregator PRIVATE Boost::dll) +set_target_properties(dll_my_plugin_aggregator + PROPERTIES + OUTPUT_NAME "my_plugin_aggregator" +) + +add_library(dll_on_unload_lib SHARED ../example/tutorial6/on_unload_lib.cpp) +target_link_libraries(dll_on_unload_lib PRIVATE Boost::dll) + +add_library(dll_library1 SHARED ../example/tutorial7/library1.cpp) +target_link_libraries(dll_library1 PRIVATE Boost::dll) + +add_library(dll_library2 SHARED ../example/tutorial7/library2.cpp) +target_link_libraries(dll_library2 PRIVATE Boost::dll) + +add_library(dll_refcounting_plugin SHARED ../example/tutorial8/refcounting_plugin.cpp) +target_link_libraries(dll_refcounting_plugin PRIVATE Boost::dll) +set_target_properties(dll_refcounting_plugin + PROPERTIES + OUTPUT_NAME "refcounting_plugin" +) + +add_library(dll_cpp_plugin SHARED cpp_test_library.cpp) +target_link_libraries(dll_cpp_plugin PRIVATE Boost::dll Boost::variant) + +add_library(dll_cpp_mangle_plugin SHARED cpp_ctti_type_name_parser_lib.cpp) +target_link_libraries(dll_cpp_mangle_plugin PRIVATE Boost::dll) + +function(boost_dll_add_test name sources export_symbols) + add_executable(${name} ${sources}) + set_target_properties(${name} PROPERTIES ENABLE_EXPORTS ${export_symbols}) + target_link_libraries(${name} PRIVATE Boost::dll Boost::filesystem) + add_test(NAME ${name} COMMAND ${name} ${ARGN}) + add_dependencies(tests ${name}) +endfunction() + +# Examples + +boost_dll_add_test(dll_example_getting_started ../example/getting_started.cpp #[[export_symbols=]] FALSE "$") + +boost_dll_add_test(dll_example_tutorial1_std_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial1_boost_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE "$") + +boost_dll_add_test(dll_example_tutorial2 ../example/tutorial2/tutorial2.cpp #[[export_symbols=]] FALSE "$") + +boost_dll_add_test(dll_example_tutorial3 ../example/tutorial3/tutorial3.cpp #[[export_symbols=]] FALSE "$" "$") + +boost_dll_add_test(dll_example_tutorial4 ../example/tutorial4/load_self.cpp #[[export_symbols=]] TRUE) +target_link_libraries(dll_example_tutorial4 PRIVATE dll_static_plugin) + +boost_dll_add_test(dll_example_tutorial5 ../example/tutorial5/load_all.cpp #[[export_symbols=]] TRUE "${CMAKE_CURRENT_BINARY_DIR}") +target_link_libraries(dll_example_tutorial5 PRIVATE dll_static_plugin) + +boost_dll_add_test(dll_example_tutorial6 ../example/tutorial6/tutorial6.cpp #[[export_symbols=]] FALSE "$") + +boost_dll_add_test(dll_example_tutorial7 ../example/tutorial7/tutorial7.cpp #[[export_symbols=]] FALSE "$" "$") + +boost_dll_add_test(dll_example_tutorial8 ../example/tutorial8/tutorial8.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial8_static ../example/tutorial8/tutorial8_static.cpp #[[export_symbols=]] TRUE) +target_link_libraries(dll_example_tutorial8_static PRIVATE dll_static_refcounting_plugin) + +boost_dll_add_test(dll_example_tutorial9 ../example/tutorial9/tutorial9.cpp #[[export_symbols=]] FALSE) + +# Tests + +add_executable(dll_test_link link1.cpp link2.cpp) +target_link_libraries(dll_test_link PRIVATE Boost::dll) + +boost_dll_add_test(dll_test_structures structures_tests.cpp #[[export_symbols=]] FALSE) +boost_dll_add_test(dll_test_cpp_mangling cpp_mangling.cpp #[[export_symbols=]] FALSE) +boost_dll_add_test(dll_test_cpp_mangle cpp_mangle_test.cpp #[[export_symbols=]] FALSE "$") +target_link_libraries(dll_test_cpp_mangle PRIVATE Boost::variant) +boost_dll_add_test(dll_test_cpp_load cpp_load_test.cpp #[[export_symbols=]] FALSE "$") +target_link_libraries(dll_test_cpp_load PRIVATE Boost::variant) +boost_dll_add_test(dll_test_cpp_import cpp_import_test.cpp #[[export_symbols=]] FALSE "$") +target_link_libraries(dll_test_cpp_import PRIVATE Boost::variant) +if(LINUX) + boost_dll_add_test(dll_test_cpp_template_method_linux template_method_linux_test.cpp #[[export_symbols=]] FALSE "$") +endif() +if(LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + boost_dll_add_test(dll_test_ctti_type_name_parser ctti_type_name_parser_test.cpp #[[export_symbols=]] FALSE "$") + target_link_libraries(dll_test_ctti_type_name_parser PRIVATE Boost::variant) +endif() +boost_dll_add_test(dll_test_shared_library_load shared_library_load_test.cpp #[[export_symbols=]] FALSE "$" "$") +boost_dll_add_test(dll_test_shared_library_search_symbol shared_library_search_symbol_test.cpp #[[export_symbols=]] TRUE "$") +boost_dll_add_test(dll_test_shared_library_get_symbol shared_library_get_symbol_test.cpp #[[export_symbols=]] TRUE "$") +boost_dll_add_test(dll_test_symbol_runtime_info symbol_runtime_info_test.cpp #[[export_symbols=]] TRUE "$") +boost_dll_add_test(dll_test_shared_library_errors shared_library_errors.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_library_info library_info_test.cpp #[[export_symbols=]] FALSE "$") +target_link_libraries(dll_test_library_info PRIVATE dll_static_plugin) +boost_dll_add_test(dll_test_broken_library_info broken_library_info_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_empty_library_info empty_library_info_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_shared_library_concurrent_load shared_library_concurrent_load_test.cpp #[[export_symbols=]] FALSE + "$" + "$" + "$" + "$" +) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 00000000..17aea2b6 --- /dev/null +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright 2026 Fedor Osetrov +# 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...4.20) + +project(cmake_subdir_test LANGUAGES CXX) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) + +set(deps + +assert +config +core +predef +system +throw_exception +type_index +winapi + +compat +container_hash +describe +variant +variant2 +integer +mp11 +fusion +function_types +detail +preprocessor +mpl +tuple +type_traits +static_assert +utility +io +typeof +functional +function +bind +filesystem +iterator +concept_check +optional +smart_ptr +scope + +) + +foreach(dep IN LISTS deps) + + add_subdirectory(../../../${dep} boostorg/${dep}) + +endforeach() + +enable_testing() +add_subdirectory(../.. boostorg/dll) From 30d237453e82f06e68d70e661d702b2e44d964db Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Mon, 13 Apr 2026 15:23:49 +0000 Subject: [PATCH 02/13] add .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..002089cf --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build* +.vscode From a8cce34259eba46e9bd3db6ffe7ec2fb8a97148e Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:06:51 +0000 Subject: [PATCH 03/13] add cmake tests in CI --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 949ab499..5cb0c38c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,7 @@ jobs: matrix: include: - toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below + compiler: g++-14 cxxstd: "11,14,17,2a" os: ubuntu-24.04 # UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags! @@ -48,6 +49,17 @@ jobs: - toolset: clang-18 cxxstd: "11,14,17,2a" os: ubuntu-24.04 + - toolset: clang-19 + compiler: clang++-19 + cxxstd: "20,23" + os: ubuntu-24.04 + install: &cxx19 + - clang-19 + - llvm-19 + - libclang-rt-19-dev + - libc++-19-dev + - libc++abi-19-dev + - clang-tools-19 #- toolset: clang # cxxstd: "11,14,17,2a" # os: macos-10.15 @@ -65,7 +77,7 @@ jobs: - name: Install packages if: matrix.install - run: sudo apt install ${{matrix.install}} + run: sudo apt install -y ${{join(matrix.install, ' ')}} - name: Setup Boost run: | @@ -92,16 +104,28 @@ jobs: ./b2 -d0 headers ./b2 -j4 variant=debug tools/inspect + - name: Run CMake subdir tests + if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}} + run: | + cd ../boost-root/ + cmake -S test/cmake_subdir_test -B __build \ + -GNinja \ + -DBUILD_TESTING=1 \ + -DCMAKE_CXX_COMPILER=${{matrix.compiler}} + cmake --build __build + ctest --test-dir __build --output-on-failure --no-tests=error + rm -rf __build + - name: Run CMake tests - if: ${{matrix.toolset == 'gcc-14'}} + if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}} 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 .. + cmake -S . -B __build \ + -DBUILD_TESTING=1 \ + -DBOOST_INCLUDE_LIBRARIES=dll \ + -DCMAKE_CXX_COMPILER=${{matrix.compiler}} + cmake --build __build --target tests + ctest --test-dir __build --output-on-failure --no-tests=error rm -rf __build - name: Run tests From 8432de007fb23012f85dab481df6f40834b790ed Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:09:48 +0000 Subject: [PATCH 04/13] up --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cb0c38c..d76406a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,6 +112,7 @@ jobs: -GNinja \ -DBUILD_TESTING=1 \ -DCMAKE_CXX_COMPILER=${{matrix.compiler}} + cmake --build __build ctest --test-dir __build --output-on-failure --no-tests=error rm -rf __build @@ -124,6 +125,7 @@ jobs: -DBUILD_TESTING=1 \ -DBOOST_INCLUDE_LIBRARIES=dll \ -DCMAKE_CXX_COMPILER=${{matrix.compiler}} + cmake --build __build --target tests ctest --test-dir __build --output-on-failure --no-tests=error rm -rf __build From 97c6ba1fc7ca1f7176886e4cb4fb52c5f501f167 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:12:03 +0000 Subject: [PATCH 05/13] fix cwd --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d76406a6..c32c1886 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: - name: Run CMake subdir tests if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}} run: | - cd ../boost-root/ + cd ../boost-root/libs/$LIBRARY cmake -S test/cmake_subdir_test -B __build \ -GNinja \ -DBUILD_TESTING=1 \ @@ -117,7 +117,7 @@ jobs: ctest --test-dir __build --output-on-failure --no-tests=error rm -rf __build - - name: Run CMake tests + - name: Run CMake root tests if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}} run: | cd ../boost-root/ From 57ea85ffb5a53489f96d0bac8593ee6911f5e197 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:29:56 +0000 Subject: [PATCH 06/13] use std::filesystem in cmake subdir tests --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c32c1886..12084d45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,6 +111,7 @@ jobs: cmake -S test/cmake_subdir_test -B __build \ -GNinja \ -DBUILD_TESTING=1 \ + -DBOOST_DLL_USE_STD_FS=1 \ -DCMAKE_CXX_COMPILER=${{matrix.compiler}} cmake --build __build From 9f20d706c7ef2f72ac149371e29d758b2ef31f66 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:36:49 +0000 Subject: [PATCH 07/13] try fix build --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12084d45..e36c4601 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,7 @@ jobs: gcov_tool: "gcov-14" ignore_coverage: "*/detail/pe_info.hpp */detail/macho_info.hpp */filesystem/src/*" - toolset: gcc-14 + compiler: g++-14 cxxstd: "17,2a" os: ubuntu-24.04 # UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags! From 8de946681a224ad02c580880c375a9ccba5869b1 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:37:55 +0000 Subject: [PATCH 08/13] try fix build --- test/cmake_subdir_test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index 17aea2b6..24ed058d 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -10,6 +10,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(deps +atomic +align assert config core From 3d97b8b2a4975392cd4eff177de21f8c7041e15e Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 08:46:16 +0000 Subject: [PATCH 09/13] fix debug tests --- .github/workflows/ci.yml | 2 +- test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e36c4601..d098f17a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: -DCMAKE_CXX_COMPILER=${{matrix.compiler}} cmake --build __build - ctest --test-dir __build --output-on-failure --no-tests=error + ctest --test-dir __build --output-on-failure --no-tests=error -VV rm -rf __build - name: Run CMake root tests diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9d24bea3..57956196 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -82,7 +82,7 @@ boost_dll_add_test(dll_example_tutorial3 ../example/tutorial3/tutorial3.cpp #[[e boost_dll_add_test(dll_example_tutorial4 ../example/tutorial4/load_self.cpp #[[export_symbols=]] TRUE) target_link_libraries(dll_example_tutorial4 PRIVATE dll_static_plugin) -boost_dll_add_test(dll_example_tutorial5 ../example/tutorial5/load_all.cpp #[[export_symbols=]] TRUE "${CMAKE_CURRENT_BINARY_DIR}") +boost_dll_add_test(dll_example_tutorial5 ../example/tutorial5/load_all.cpp #[[export_symbols=]] TRUE "$" "$" "$") target_link_libraries(dll_example_tutorial5 PRIVATE dll_static_plugin) boost_dll_add_test(dll_example_tutorial6 ../example/tutorial6/tutorial6.cpp #[[export_symbols=]] FALSE "$") From 3bb90299fb6e65e36154589bb782ef7480747052 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sat, 18 Apr 2026 09:23:13 +0000 Subject: [PATCH 10/13] add shared libraries to dependencies --- test/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 57956196..7b448fe7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,17 +12,22 @@ endif() add_library(dll_static_plugin STATIC ../example/tutorial4/static_plugin.cpp) target_link_libraries(dll_static_plugin PRIVATE Boost::dll) +add_dependencies(tests dll_static_plugin) add_library(dll_static_refcounting_plugin STATIC ../example/tutorial8/refcounting_plugin.cpp) target_link_libraries(dll_static_refcounting_plugin PRIVATE Boost::dll) +add_dependencies(tests dll_static_refcounting_plugin) add_library(dll_test_library SHARED test_library.cpp) target_link_libraries(dll_test_library PRIVATE Boost::dll Boost::fusion) +add_dependencies(tests dll_test_library) add_library(dll_empty_library SHARED empty_library.cpp) +add_dependencies(tests dll_empty_library) add_library(dll_getting_started_library SHARED ../example/getting_started_library.cpp) target_link_libraries(dll_getting_started_library PRIVATE Boost::dll) +add_dependencies(tests dll_getting_started_library) add_library(dll_my_plugin_sum SHARED ../example/tutorial1/my_plugin_sum.cpp) target_link_libraries(dll_my_plugin_sum PRIVATE Boost::dll) @@ -30,6 +35,7 @@ set_target_properties(dll_my_plugin_sum PROPERTIES OUTPUT_NAME "my_plugin_sum" ) +add_dependencies(tests dll_my_plugin_sum) add_library(dll_my_plugin_aggregator SHARED ../example/tutorial2/my_plugin_aggregator.cpp) target_link_libraries(dll_my_plugin_aggregator PRIVATE Boost::dll) @@ -37,15 +43,19 @@ set_target_properties(dll_my_plugin_aggregator PROPERTIES OUTPUT_NAME "my_plugin_aggregator" ) +add_dependencies(tests dll_my_plugin_aggregator) add_library(dll_on_unload_lib SHARED ../example/tutorial6/on_unload_lib.cpp) target_link_libraries(dll_on_unload_lib PRIVATE Boost::dll) +add_dependencies(tests dll_on_unload_lib) add_library(dll_library1 SHARED ../example/tutorial7/library1.cpp) target_link_libraries(dll_library1 PRIVATE Boost::dll) +add_dependencies(tests dll_library1) add_library(dll_library2 SHARED ../example/tutorial7/library2.cpp) target_link_libraries(dll_library2 PRIVATE Boost::dll) +add_dependencies(tests dll_library2) add_library(dll_refcounting_plugin SHARED ../example/tutorial8/refcounting_plugin.cpp) target_link_libraries(dll_refcounting_plugin PRIVATE Boost::dll) @@ -53,12 +63,15 @@ set_target_properties(dll_refcounting_plugin PROPERTIES OUTPUT_NAME "refcounting_plugin" ) +add_dependencies(tests dll_refcounting_plugin) add_library(dll_cpp_plugin SHARED cpp_test_library.cpp) target_link_libraries(dll_cpp_plugin PRIVATE Boost::dll Boost::variant) +add_dependencies(tests dll_cpp_plugin) add_library(dll_cpp_mangle_plugin SHARED cpp_ctti_type_name_parser_lib.cpp) target_link_libraries(dll_cpp_mangle_plugin PRIVATE Boost::dll) +add_dependencies(tests dll_cpp_mangle_plugin) function(boost_dll_add_test name sources export_symbols) add_executable(${name} ${sources}) From af1c6ac5c7c6012600f6afcb1161f19d67139a02 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sun, 19 Apr 2026 07:30:01 +0000 Subject: [PATCH 11/13] depend each test from its args --- .gitignore | 1 + test/CMakeLists.txt | 63 ++++++++++++++++++++++----------------- test/cpp_test_library.cpp | 1 - 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 002089cf..0295863d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.cache build* .vscode diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7b448fe7..9d3fe3e3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -66,7 +66,7 @@ set_target_properties(dll_refcounting_plugin add_dependencies(tests dll_refcounting_plugin) add_library(dll_cpp_plugin SHARED cpp_test_library.cpp) -target_link_libraries(dll_cpp_plugin PRIVATE Boost::dll Boost::variant) +target_link_libraries(dll_cpp_plugin PRIVATE Boost::variant) add_dependencies(tests dll_cpp_plugin) add_library(dll_cpp_mangle_plugin SHARED cpp_ctti_type_name_parser_lib.cpp) @@ -77,32 +77,39 @@ function(boost_dll_add_test name sources export_symbols) add_executable(${name} ${sources}) set_target_properties(${name} PROPERTIES ENABLE_EXPORTS ${export_symbols}) target_link_libraries(${name} PRIVATE Boost::dll Boost::filesystem) - add_test(NAME ${name} COMMAND ${name} ${ARGN}) + + set(test_args) + foreach(lib IN LISTS ARGN) + list(APPEND test_args "$") + endforeach() + add_test(NAME ${name} COMMAND ${name} ${test_args}) + + add_dependencies(${name} ${ARGN}) add_dependencies(tests ${name}) endfunction() # Examples -boost_dll_add_test(dll_example_getting_started ../example/getting_started.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_getting_started ../example/getting_started.cpp #[[export_symbols=]] FALSE dll_getting_started_library) -boost_dll_add_test(dll_example_tutorial1_std_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE "$") -boost_dll_add_test(dll_example_tutorial1_boost_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial1_std_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE dll_my_plugin_sum) +boost_dll_add_test(dll_example_tutorial1_boost_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE dll_my_plugin_sum) -boost_dll_add_test(dll_example_tutorial2 ../example/tutorial2/tutorial2.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial2 ../example/tutorial2/tutorial2.cpp #[[export_symbols=]] FALSE dll_my_plugin_aggregator) -boost_dll_add_test(dll_example_tutorial3 ../example/tutorial3/tutorial3.cpp #[[export_symbols=]] FALSE "$" "$") +boost_dll_add_test(dll_example_tutorial3 ../example/tutorial3/tutorial3.cpp #[[export_symbols=]] FALSE dll_my_plugin_sum dll_my_plugin_aggregator) boost_dll_add_test(dll_example_tutorial4 ../example/tutorial4/load_self.cpp #[[export_symbols=]] TRUE) target_link_libraries(dll_example_tutorial4 PRIVATE dll_static_plugin) -boost_dll_add_test(dll_example_tutorial5 ../example/tutorial5/load_all.cpp #[[export_symbols=]] TRUE "$" "$" "$") +boost_dll_add_test(dll_example_tutorial5 ../example/tutorial5/load_all.cpp #[[export_symbols=]] TRUE dll_getting_started_library dll_my_plugin_aggregator dll_my_plugin_sum) target_link_libraries(dll_example_tutorial5 PRIVATE dll_static_plugin) -boost_dll_add_test(dll_example_tutorial6 ../example/tutorial6/tutorial6.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial6 ../example/tutorial6/tutorial6.cpp #[[export_symbols=]] FALSE dll_on_unload_lib) -boost_dll_add_test(dll_example_tutorial7 ../example/tutorial7/tutorial7.cpp #[[export_symbols=]] FALSE "$" "$") +boost_dll_add_test(dll_example_tutorial7 ../example/tutorial7/tutorial7.cpp #[[export_symbols=]] FALSE dll_library1 dll_library2) -boost_dll_add_test(dll_example_tutorial8 ../example/tutorial8/tutorial8.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_example_tutorial8 ../example/tutorial8/tutorial8.cpp #[[export_symbols=]] FALSE dll_refcounting_plugin) boost_dll_add_test(dll_example_tutorial8_static ../example/tutorial8/tutorial8_static.cpp #[[export_symbols=]] TRUE) target_link_libraries(dll_example_tutorial8_static PRIVATE dll_static_refcounting_plugin) @@ -115,31 +122,31 @@ target_link_libraries(dll_test_link PRIVATE Boost::dll) boost_dll_add_test(dll_test_structures structures_tests.cpp #[[export_symbols=]] FALSE) boost_dll_add_test(dll_test_cpp_mangling cpp_mangling.cpp #[[export_symbols=]] FALSE) -boost_dll_add_test(dll_test_cpp_mangle cpp_mangle_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_cpp_mangle cpp_mangle_test.cpp #[[export_symbols=]] FALSE dll_cpp_plugin) target_link_libraries(dll_test_cpp_mangle PRIVATE Boost::variant) -boost_dll_add_test(dll_test_cpp_load cpp_load_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_cpp_load cpp_load_test.cpp #[[export_symbols=]] FALSE dll_cpp_plugin) target_link_libraries(dll_test_cpp_load PRIVATE Boost::variant) -boost_dll_add_test(dll_test_cpp_import cpp_import_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_cpp_import cpp_import_test.cpp #[[export_symbols=]] FALSE dll_cpp_plugin) target_link_libraries(dll_test_cpp_import PRIVATE Boost::variant) if(LINUX) - boost_dll_add_test(dll_test_cpp_template_method_linux template_method_linux_test.cpp #[[export_symbols=]] FALSE "$") + boost_dll_add_test(dll_test_cpp_template_method_linux template_method_linux_test.cpp #[[export_symbols=]] FALSE dll_cpp_plugin) endif() if(LINUX AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - boost_dll_add_test(dll_test_ctti_type_name_parser ctti_type_name_parser_test.cpp #[[export_symbols=]] FALSE "$") + boost_dll_add_test(dll_test_ctti_type_name_parser ctti_type_name_parser_test.cpp #[[export_symbols=]] FALSE dll_cpp_mangle_plugin) target_link_libraries(dll_test_ctti_type_name_parser PRIVATE Boost::variant) endif() -boost_dll_add_test(dll_test_shared_library_load shared_library_load_test.cpp #[[export_symbols=]] FALSE "$" "$") -boost_dll_add_test(dll_test_shared_library_search_symbol shared_library_search_symbol_test.cpp #[[export_symbols=]] TRUE "$") -boost_dll_add_test(dll_test_shared_library_get_symbol shared_library_get_symbol_test.cpp #[[export_symbols=]] TRUE "$") -boost_dll_add_test(dll_test_symbol_runtime_info symbol_runtime_info_test.cpp #[[export_symbols=]] TRUE "$") -boost_dll_add_test(dll_test_shared_library_errors shared_library_errors.cpp #[[export_symbols=]] FALSE "$") -boost_dll_add_test(dll_test_library_info library_info_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_shared_library_load shared_library_load_test.cpp #[[export_symbols=]] FALSE dll_test_library dll_library1) +boost_dll_add_test(dll_test_shared_library_search_symbol shared_library_search_symbol_test.cpp #[[export_symbols=]] TRUE dll_test_library) +boost_dll_add_test(dll_test_shared_library_get_symbol shared_library_get_symbol_test.cpp #[[export_symbols=]] TRUE dll_test_library) +boost_dll_add_test(dll_test_symbol_runtime_info symbol_runtime_info_test.cpp #[[export_symbols=]] TRUE dll_test_library) +boost_dll_add_test(dll_test_shared_library_errors shared_library_errors.cpp #[[export_symbols=]] FALSE dll_test_library) +boost_dll_add_test(dll_test_library_info library_info_test.cpp #[[export_symbols=]] FALSE dll_test_library) target_link_libraries(dll_test_library_info PRIVATE dll_static_plugin) -boost_dll_add_test(dll_test_broken_library_info broken_library_info_test.cpp #[[export_symbols=]] FALSE "$") -boost_dll_add_test(dll_test_empty_library_info empty_library_info_test.cpp #[[export_symbols=]] FALSE "$") +boost_dll_add_test(dll_test_broken_library_info broken_library_info_test.cpp #[[export_symbols=]] FALSE dll_test_library) +boost_dll_add_test(dll_test_empty_library_info empty_library_info_test.cpp #[[export_symbols=]] FALSE dll_empty_library) boost_dll_add_test(dll_test_shared_library_concurrent_load shared_library_concurrent_load_test.cpp #[[export_symbols=]] FALSE - "$" - "$" - "$" - "$" + dll_library1 + dll_library2 + dll_my_plugin_aggregator + dll_refcounting_plugin ) diff --git a/test/cpp_test_library.cpp b/test/cpp_test_library.cpp index fb47ce18..3a694465 100644 --- a/test/cpp_test_library.cpp +++ b/test/cpp_test_library.cpp @@ -9,7 +9,6 @@ #include -#include #include BOOST_SYMBOL_EXPORT extern int unscoped_var; From aa2e1963584927d5cf206b6ac59c53631f6b8094 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sun, 19 Apr 2026 07:44:29 +0000 Subject: [PATCH 12/13] remove redundant add_dependencies, fix no args add_dependencies --- test/CMakeLists.txt | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9d3fe3e3..d2edbc00 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,22 +12,17 @@ endif() add_library(dll_static_plugin STATIC ../example/tutorial4/static_plugin.cpp) target_link_libraries(dll_static_plugin PRIVATE Boost::dll) -add_dependencies(tests dll_static_plugin) add_library(dll_static_refcounting_plugin STATIC ../example/tutorial8/refcounting_plugin.cpp) target_link_libraries(dll_static_refcounting_plugin PRIVATE Boost::dll) -add_dependencies(tests dll_static_refcounting_plugin) add_library(dll_test_library SHARED test_library.cpp) target_link_libraries(dll_test_library PRIVATE Boost::dll Boost::fusion) -add_dependencies(tests dll_test_library) add_library(dll_empty_library SHARED empty_library.cpp) -add_dependencies(tests dll_empty_library) add_library(dll_getting_started_library SHARED ../example/getting_started_library.cpp) target_link_libraries(dll_getting_started_library PRIVATE Boost::dll) -add_dependencies(tests dll_getting_started_library) add_library(dll_my_plugin_sum SHARED ../example/tutorial1/my_plugin_sum.cpp) target_link_libraries(dll_my_plugin_sum PRIVATE Boost::dll) @@ -35,7 +30,6 @@ set_target_properties(dll_my_plugin_sum PROPERTIES OUTPUT_NAME "my_plugin_sum" ) -add_dependencies(tests dll_my_plugin_sum) add_library(dll_my_plugin_aggregator SHARED ../example/tutorial2/my_plugin_aggregator.cpp) target_link_libraries(dll_my_plugin_aggregator PRIVATE Boost::dll) @@ -43,19 +37,15 @@ set_target_properties(dll_my_plugin_aggregator PROPERTIES OUTPUT_NAME "my_plugin_aggregator" ) -add_dependencies(tests dll_my_plugin_aggregator) add_library(dll_on_unload_lib SHARED ../example/tutorial6/on_unload_lib.cpp) target_link_libraries(dll_on_unload_lib PRIVATE Boost::dll) -add_dependencies(tests dll_on_unload_lib) add_library(dll_library1 SHARED ../example/tutorial7/library1.cpp) target_link_libraries(dll_library1 PRIVATE Boost::dll) -add_dependencies(tests dll_library1) add_library(dll_library2 SHARED ../example/tutorial7/library2.cpp) target_link_libraries(dll_library2 PRIVATE Boost::dll) -add_dependencies(tests dll_library2) add_library(dll_refcounting_plugin SHARED ../example/tutorial8/refcounting_plugin.cpp) target_link_libraries(dll_refcounting_plugin PRIVATE Boost::dll) @@ -63,15 +53,12 @@ set_target_properties(dll_refcounting_plugin PROPERTIES OUTPUT_NAME "refcounting_plugin" ) -add_dependencies(tests dll_refcounting_plugin) add_library(dll_cpp_plugin SHARED cpp_test_library.cpp) target_link_libraries(dll_cpp_plugin PRIVATE Boost::variant) -add_dependencies(tests dll_cpp_plugin) add_library(dll_cpp_mangle_plugin SHARED cpp_ctti_type_name_parser_lib.cpp) target_link_libraries(dll_cpp_mangle_plugin PRIVATE Boost::dll) -add_dependencies(tests dll_cpp_mangle_plugin) function(boost_dll_add_test name sources export_symbols) add_executable(${name} ${sources}) @@ -84,7 +71,9 @@ function(boost_dll_add_test name sources export_symbols) endforeach() add_test(NAME ${name} COMMAND ${name} ${test_args}) - add_dependencies(${name} ${ARGN}) + if(ARGN) + add_dependencies(${name} ${ARGN}) + endif() add_dependencies(tests ${name}) endfunction() From eff8c4b73622b73b504ea7b6eef86e820f3d5b99 Mon Sep 17 00:00:00 2001 From: Fedor Osetrov Date: Sun, 19 Apr 2026 07:53:49 +0000 Subject: [PATCH 13/13] fix boost_shared_ptr test --- test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d2edbc00..1bd2f2aa 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -83,6 +83,7 @@ boost_dll_add_test(dll_example_getting_started ../example/getting_started.cpp #[ boost_dll_add_test(dll_example_tutorial1_std_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE dll_my_plugin_sum) boost_dll_add_test(dll_example_tutorial1_boost_shared_ptr ../example/tutorial1/tutorial1.cpp #[[export_symbols=]] FALSE dll_my_plugin_sum) +target_compile_definitions(dll_example_tutorial1_boost_shared_ptr PRIVATE BOOST_DLL_USE_BOOST_SHARED_PTR) boost_dll_add_test(dll_example_tutorial2 ../example/tutorial2/tutorial2.cpp #[[export_symbols=]] FALSE dll_my_plugin_aggregator)