From 3fedc68230bad234694fc8dd8270c019fdb100a0 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:24:27 -0700 Subject: [PATCH] common: Only use libbacktrace if present. (#6827) --- src/common/CMakeLists.txt | 7 +++++-- src/common/logging/backend.cpp | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index ddf715f2f4..d5500a4322 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -176,6 +176,9 @@ endif() if (CITRA_USE_PRECOMPILED_HEADERS) target_precompile_headers(citra_common PRIVATE precompiled_headers.h) endif() -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) - target_link_libraries(citra_common PRIVATE backtrace dl) + +find_library(BACKTRACE_LIBRARY backtrace) +if (BACKTRACE_LIBRARY AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND CMAKE_CXX_COMPILER_ID STREQUAL GNU) + target_link_libraries(citra_common PRIVATE ${BACKTRACE_LIBRARY} dl) + target_compile_definitions(citra_common PRIVATE CITRA_LINUX_GCC_BACKTRACE) endif() diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 5c80cdff0f..f39c79dea0 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -13,12 +13,11 @@ #define _SH_DENYWR 0 #endif -#if defined(__linux__) && defined(__GNUG__) && !defined(__clang__) +#ifdef CITRA_LINUX_GCC_BACKTRACE #define BOOST_STACKTRACE_USE_BACKTRACE #include #undef BOOST_STACKTRACE_USE_BACKTRACE #include -#define CITRA_LINUX_GCC_BACKTRACE #endif #include "common/bounded_threadsafe_queue.h"