Skip to content

Commit

Permalink
Merge pull request #40 from project-tsurugi/boost-stacktrace-fallback
Browse files Browse the repository at this point in the history
fall back to Boost::stacktrace_basic if Boost::stacktrace_backtrace is not available
  • Loading branch information
ban-nobuhiro committed Dec 10, 2024
2 parents f8d05b0 + 9f18def commit 0429e36
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.65
COMPONENTS container
COMPONENTS stacktrace_backtrace
OPTIONAL_COMPONENTS stacktrace_backtrace stacktrace_basic
REQUIRED)
if(Boost_STACKTRACE_BACKTRACE_FOUND
AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set(boost_stacktrace_component stacktrace_backtrace)
elseif(Boost_STACKTRACE_BASIC_FOUND)
set(boost_stacktrace_component stacktrace_basic)
else()
message(FATAL_ERROR "No usable Boost stacktrace component")
endif()

find_package(Doxygen
OPTIONAL_COMPONENTS dot)
Expand Down
3 changes: 3 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
include(CMakeFindDependencyMacro)
find_dependency(Boost 1.65 COMPONENTS @boost_stacktrace_component@ REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ target_compile_definitions(takatori
PUBLIC BOOST_ENABLE_ASSERT_DEBUG_HANDLER
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (boost_stacktrace_component STREQUAL "stacktrace_backtrace")
target_link_libraries(takatori
PUBLIC Boost::stacktrace_backtrace
PUBLIC ${CMAKE_DL_LIBS}
Expand All @@ -254,9 +254,9 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
PUBLIC BOOST_STACKTRACE_USE_BACKTRACE
)
else()
# FIXME: more compilers
target_link_libraries(takatori
PUBLIC Boost::stacktrace_noop
PUBLIC Boost::stacktrace_basic
PUBLIC ${CMAKE_DL_LIBS}
)
endif()

Expand Down

0 comments on commit 0429e36

Please sign in to comment.