More tests and docs on CMake installation (#213)

This commit is contained in:
Antony Polukhin
2025-12-24 20:05:46 +03:00
committed by GitHub
parent 77647f8b06
commit b2f10f7efd
5 changed files with 55 additions and 13 deletions

View File

@@ -266,10 +266,21 @@ jobs:
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
ctest --output-on-failure --no-tests=error
set -e
if [[ "$OSTYPE" == "darwin"* ]]; then
BACKENDS_ARRAY=(stacktrace stacktrace_noop stacktrace_basic)
else
BACKENDS_ARRAY=(stacktrace stacktrace_noop stacktrace_basic stacktrace_backtrace)
fi
for BACKEND in ${BACKENDS_ARRAY[@]}; do
rm -rf *
cmake -DCMAKE_INSTALL_PREFIX=~/.local -DBOOST_STACKTRACE_IMPL_BACKEND=${BACKEND} ..
cmake --build .
ctest --output-on-failure --no-tests=error -V
done
posix-cmake-test:
strategy:
@@ -426,10 +437,20 @@ jobs:
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace ..
cmake --build . --config Debug
PATH C:\cmake-prefix\bin;%PATH%
ctest --output-on-failure --no-tests=error -C Debug
ctest --output-on-failure --no-tests=error -C Debug -V
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace_windbg ..
cmake --build . --config Debug
PATH C:\cmake-prefix\bin;%PATH%
ctest --output-on-failure --no-tests=error -C Debug -V
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix -DBOOST_STACKTRACE_IMPL_BACKEND=stacktrace_windbg_cached ..
cmake --build . --config Debug
PATH C:\cmake-prefix\bin;%PATH%
ctest --output-on-failure --no-tests=error -C Debug -V
- name: Use the installed library (RelWithDebInfo)
shell: cmd

View File

@@ -2,7 +2,7 @@
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
cmake_minimum_required(VERSION 3.8...4.20)
project(boost_stacktrace VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
@@ -142,8 +142,6 @@ stacktrace_add_library(from_exception ${BOOST_STACKTRACE_ENABLE_FROM_EXCEPTION}
#
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -334,6 +334,17 @@ target_link_libraries(${PROJECT} # your project
)
```
If Boost is installed into the system the best way to get it for your project
is via `find_package`:
```
find_package(
Boost
REQUIRED stacktrace stacktrace_from_exception
CONFIG
)
```
[endsect]
[section CMake build notes]

View File

@@ -2,14 +2,21 @@
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.20)
cmake_minimum_required(VERSION 3.8...4.20)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_stacktrace REQUIRED)
find_package(
Boost
REQUIRED stacktrace ${BOOST_STACKTRACE_IMPL_BACKEND} stacktrace_from_exception
CONFIG
)
add_executable(main main.cpp)
target_link_libraries(main Boost::stacktrace)
target_link_libraries(main Boost::${BOOST_STACKTRACE_IMPL_BACKEND})
add_executable(main_from_exception main.cpp)
target_link_libraries(main_from_exception Boost::stacktrace_from_exception Boost::${BOOST_STACKTRACE_IMPL_BACKEND})
enable_testing()
add_test(main main)
add_test(main_from_exception main_from_exception)

View File

@@ -9,4 +9,9 @@
int main()
{
std::cout << boost::stacktrace::stacktrace() << std::endl;
try {
throw 42;
} catch (...) {
std::cout << "From current excption:\n" << boost::stacktrace::stacktrace::from_current_exception() << std::endl;
}
}