Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -34,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!
Expand All @@ -48,6 +50,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
Expand All @@ -65,7 +78,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: |
Expand All @@ -92,16 +105,31 @@ jobs:
./b2 -d0 headers
./b2 -j4 variant=debug tools/inspect

- name: Run CMake tests
if: ${{matrix.toolset == 'gcc-14'}}
- name: Run CMake subdir tests
if: ${{matrix.toolset == 'gcc-14' || matrix.toolset == 'clang-19'}}
run: |
cd ../boost-root/libs/$LIBRARY
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
ctest --test-dir __build --output-on-failure --no-tests=error -VV
rm -rf __build

- name: Run CMake root tests
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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.cache
build*
.vscode
136 changes: 132 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -7,8 +8,135 @@ 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::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)

set(test_args)
foreach(lib IN LISTS ARGN)
list(APPEND test_args "$<TARGET_FILE:${lib}>")
endforeach()
add_test(NAME ${name} COMMAND ${name} ${test_args})

if(ARGN)
add_dependencies(${name} ${ARGN})
endif()
add_dependencies(tests ${name})
endfunction()

# Examples

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 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)

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 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 dll_on_unload_lib)

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 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)

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 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 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 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 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 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 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 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
)
61 changes: 61 additions & 0 deletions test/cmake_subdir_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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

atomic
align
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)
1 change: 0 additions & 1 deletion test/cpp_test_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <boost/config.hpp>

#include <boost/dll/config.hpp>
#include <boost/variant.hpp>

BOOST_SYMBOL_EXPORT extern int unscoped_var;
Expand Down
Loading