From b87798fe9fed746e98871aaa10978324e4b9378f Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Tue, 1 Mar 2022 21:29:32 +0000 Subject: [PATCH] Fix musl build by checking whether execinfo.h's backtrace is present Closes: https://github.com/odamex/odamex/issues/533 (cherry picked from commit df3f5976416d342198879db80e4bf35f69eb2ed7) --- common/CMakeLists.txt | 9 +++++++++ common/i_crash_noop.cpp | 2 +- common/i_crash_posix.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2850607e5..8d02b3212 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -6,3 +6,12 @@ configure_file(git_describe.h.in "${CMAKE_CURRENT_BINARY_DIR}/git_describe.h") add_library(odamex-common INTERFACE) target_sources(odamex-common INTERFACE ${COMMON_SOURCES} ${COMMON_HEADERS}) target_include_directories(odamex-common INTERFACE . ${CMAKE_CURRENT_BINARY_DIR}) + +if(UNIX) + include(CheckSymbolExists) + check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) + + if(HAVE_BACKTRACE) + target_compile_definitions(odamex-common INTERFACE HAVE_BACKTRACE) + endif() +endif() diff --git a/common/i_crash_noop.cpp b/common/i_crash_noop.cpp index 4eb8e70f4..84a406fb3 100644 --- a/common/i_crash_noop.cpp +++ b/common/i_crash_noop.cpp @@ -23,7 +23,7 @@ #if defined _WIN32 && !defined _XBOX && defined _MSC_VER && !defined _DEBUG -#elif defined UNIX && !defined GEKKO +#elif defined UNIX && defined HAVE_BACKTRACE && !defined GEKKO #else #include "odamex.h" diff --git a/common/i_crash_posix.cpp b/common/i_crash_posix.cpp index 8e6270872..4bf8727f6 100644 --- a/common/i_crash_posix.cpp +++ b/common/i_crash_posix.cpp @@ -22,7 +22,7 @@ //----------------------------------------------------------------------------- -#if defined UNIX && !defined GCONSOLE +#if defined UNIX && defined HAVE_BACKTRACE && !defined GCONSOLE #include "odamex.h" -- 2.34.1