Skip to content

Commit 886a245

Browse files
committed
More tests and docs on CMake installation
1 parent cf59922 commit 886a245

File tree

5 files changed

+50
-13
lines changed

5 files changed

+50
-13
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
env:
1212
UBSAN_OPTIONS: print_stacktrace=1
13+
BOOST_SUPERPROJECT_VERSION: 1.88 # minimal Boost version for the CMake install tests
1314

1415
jobs:
1516
posix:
@@ -265,10 +266,15 @@ jobs:
265266
- name: Use the installed library
266267
run: |
267268
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
268-
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
269-
cmake --build .
270-
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
271-
ctest --output-on-failure --no-tests=error
269+
270+
set -e
271+
for BACKEND in stacktrace stacktrace_noop stacktrace_basic stacktrace_backtrace; do
272+
rm -rf *
273+
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_STACKTRACE_IMPL_BACKEND=${BACKEND} ..
274+
cmake --build .
275+
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
276+
ctest --output-on-failure --no-tests=error -V
277+
done
272278
273279
posix-cmake-test:
274280
strategy:
@@ -425,10 +431,20 @@ jobs:
425431
shell: cmd
426432
run: |
427433
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
428-
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
434+
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace ..
429435
cmake --build . --config Debug
430436
PATH C:\cmake-prefix\bin;%PATH%
431-
ctest --output-on-failure --no-tests=error -C Debug
437+
ctest --output-on-failure --no-tests=error -C Debug -V
438+
439+
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace_windbg ..
440+
cmake --build . --config Debug
441+
PATH C:\cmake-prefix\bin;%PATH%
442+
ctest --output-on-failure --no-tests=error -C Debug -V
443+
444+
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace_windbg_cached ..
445+
cmake --build . --config Debug
446+
PATH C:\cmake-prefix\bin;%PATH%
447+
ctest --output-on-failure --no-tests=error -C Debug -V
432448
433449
- name: Use the installed library (RelWithDebInfo)
434450
shell: cmd

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ stacktrace_add_library(from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION}
142142

143143
#
144144

145-
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
146-
145+
if(BUILD_TESTING)
147146
add_subdirectory(test)
148-
149147
endif()

doc/stacktrace.qbk

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ target_link_libraries(${PROJECT} # your project
334334
)
335335
```
336336

337+
If Boost is installed into the system the best way to get it for your project
338+
is via `find_package`:
339+
340+
```
341+
find_package(
342+
Boost 1.88 # Boost minimal version
343+
REQUIRED stacktrace stacktrace_from_exception
344+
CONFIG
345+
)
346+
```
347+
337348
[endsect]
338349

339350
[section CMake build notes]

test/cmake_install_test/CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
# Distributed under the Boost Software License, Version 1.0.
33
# https://www.boost.org/LICENSE_1_0.txt
44

5-
cmake_minimum_required(VERSION 3.5...3.20)
5+
cmake_minimum_required(VERSION 3.5...4.20)
66

77
project(cmake_install_test LANGUAGES CXX)
88

9-
find_package(boost_stacktrace REQUIRED)
10-
9+
find_package(
10+
Boost "$ENV{BOOST_SUPERPROJECT_VERSION}"
11+
REQUIRED ${BOOST_STACKTRACE_IMPL_BACKEND} stacktrace_from_exception
12+
CONFIG
13+
)
1114
add_executable(main main.cpp)
12-
target_link_libraries(main Boost::stacktrace)
15+
target_link_libraries(main Boost::${BOOST_STACKTRACE_IMPL_BACKEND})
16+
17+
add_executable(main_from_exception main.cpp)
18+
target_link_libraries(main_from_exception Boost::stacktrace_from_exception Boost::${BOOST_STACKTRACE_IMPL_BACKEND})
1319

1420
enable_testing()
1521
add_test(main main)
22+
add_test(main_from_exception main_from_exception)

test/cmake_install_test/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
int main()
1010
{
1111
std::cout << boost::stacktrace::stacktrace() << std::endl;
12+
try {
13+
throw 42;
14+
} catch (...) {
15+
std::cout << "From current excption:\n" << boost::stacktrace::stacktrace::from_current_exception() << std::endl;
16+
}
1217
}

0 commit comments

Comments
 (0)