Skip to content

Commit 4105c3a

Browse files
authored
Test CMake in CI and add initial CMakeLists.txt for tests (#100)
1 parent 67ded46 commit 4105c3a

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
include:
27-
- toolset: gcc-14
27+
- toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below
2828
cxxstd: "11,14,17,2a"
2929
os: ubuntu-24.04
3030
# UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags!
@@ -92,6 +92,18 @@ jobs:
9292
./b2 -d0 headers
9393
./b2 -j4 variant=debug tools/inspect
9494
95+
- name: Run CMake tests
96+
if: ${{matrix.toolset == 'gcc-14'}}
97+
run: |
98+
cd ../boost-root/
99+
mkdir __build
100+
cd __build
101+
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=dll -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 ..
102+
cmake --build . --target tests
103+
ctest --output-on-failure --no-tests=error
104+
cd ..
105+
rm -rf __build
106+
95107
- name: Run tests
96108
run: |
97109
cd ../boost-root

CMakeLists.txt

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ project(boost_dll VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
1010

1111
option(BOOST_DLL_USE_STD_FS "Use std::filesystem instead of Boost.Filesystem" OFF)
1212

13-
add_library(boost_dll INTERFACE)
14-
add_library(Boost::dll ALIAS boost_dll)
15-
16-
target_include_directories(boost_dll INTERFACE include)
17-
18-
target_link_libraries(boost_dll
13+
add_library(boost_dll_base INTERFACE)
14+
target_include_directories(boost_dll_base INTERFACE include)
15+
target_link_libraries(boost_dll_base
1916
INTERFACE
2017
Boost::assert
2118
Boost::config
@@ -28,13 +25,32 @@ target_link_libraries(boost_dll
2825
${CMAKE_DL_LIBS}
2926
)
3027

28+
29+
add_library(boost_dll_std_fs INTERFACE)
30+
target_link_libraries(boost_dll_std_fs
31+
INTERFACE
32+
boost_dll_base
33+
)
34+
target_compile_definitions(boost_dll_std_fs INTERFACE BOOST_DLL_USE_STD_FS)
35+
target_compile_features(boost_dll_std_fs INTERFACE cxx_std_17)
36+
37+
add_library(boost_dll_boost_fs INTERFACE)
38+
target_link_libraries(boost_dll_boost_fs
39+
INTERFACE
40+
boost_dll_base
41+
Boost::filesystem
42+
)
43+
44+
45+
add_library(boost_dll INTERFACE)
3146
if(BOOST_DLL_USE_STD_FS)
32-
target_compile_definitions(boost_dll INTERFACE BOOST_DLL_USE_STD_FS)
33-
target_compile_features(boost_dll INTERFACE cxx_std_17)
47+
target_link_libraries(boost_dll INTERFACE boost_dll_std_fs)
3448
else()
35-
target_link_libraries(boost_dll INTERFACE Boost::filesystem)
49+
target_link_libraries(boost_dll INTERFACE boost_dll_boost_fs)
3650
endif()
3751

52+
add_library(Boost::dll ALIAS boost_dll)
53+
3854
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
3955

4056
add_subdirectory(test)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Boost.DLL is a part of the [Boost C++ Libraries](https://github.com/boostorg). I
66

77
Branches | Build | Tests coverage | More info
88
----------------|-------------- | -------------- |-----------
9-
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)
10-
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)
9+
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)
10+
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)
1111

1212
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/boost_dll.html)
1313

test/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2016-2025 Antony Polukhin
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
4+
5+
if(NOT TARGET tests)
6+
add_custom_target(tests)
7+
endif()
8+
9+
add_executable(dll_tests_cpp_mangling "cpp_mangling.cpp")
10+
target_link_libraries(dll_tests_cpp_mangling Boost::dll)
11+
add_test(NAME dll_tests_cpp_mangling COMMAND dll_tests_cpp_mangling)
12+
add_dependencies(tests dll_tests_cpp_mangling)
13+

0 commit comments

Comments
 (0)