From ab053a074935221fe44bd2c95b3a2832bd146c9c Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Mon, 15 Jul 2024 20:11:17 -0400 Subject: [PATCH] linux/cmake: Allow libbacktrace to be disabled --- cmake/BuildParameters.cmake | 1 + cmake/SearchForStuff.cmake | 5 ++++- common/CMakeLists.txt | 5 ++++- common/CrashHandler.cpp | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 2e24f1f1c043e..31ffca414f9f9 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -23,6 +23,7 @@ if(UNIX AND NOT APPLE) option(ENABLE_SETCAP "Enable networking capability for DEV9" OFF) option(X11_API "Enable X11 support" ON) option(WAYLAND_API "Enable Wayland support" ON) + option(USE_BACKTRACE "Enable libbacktrace support" ON) endif() if(UNIX) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 0315610a9c694..80c444af73a68 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -65,7 +65,10 @@ else() find_package(Wayland REQUIRED Egl) endif() - find_package(Libbacktrace REQUIRED) + if(USE_BACKTRACE) + find_package(Libbacktrace REQUIRED) + endif() + find_package(PkgConfig REQUIRED) pkg_check_modules(DBUS REQUIRED dbus-1) endif() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 59c1c52aa6427..8f3c90071ebdb 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -167,10 +167,13 @@ else() ) target_link_libraries(common PRIVATE ${DBUS_LINK_LIBRARIES} - libbacktrace::libbacktrace X11::X11 X11::Xrandr ) + if(USE_BACKTRACE) + target_compile_definitions(common PRIVATE "HAS_LIBBACKTRACE=1") + target_link_libraries(common PRIVATE libbacktrace::libbacktrace) + endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") target_link_libraries(common PRIVATE cpuinfo) endif() diff --git a/common/CrashHandler.cpp b/common/CrashHandler.cpp index 667cc92c232ae..10c80f08a4f02 100644 --- a/common/CrashHandler.cpp +++ b/common/CrashHandler.cpp @@ -176,7 +176,7 @@ void CrashHandler::WriteDumpForCaller() WriteMinidumpAndCallstack(nullptr); } -#elif !defined(__APPLE__) +#elif !defined(__APPLE__) && defined(HAS_LIBBACKTRACE) #include "FileSystem.h" @@ -377,4 +377,4 @@ void CrashHandler::CrashSignalHandler(int signal, siginfo_t* siginfo, void* ctx) std::abort(); } -#endif \ No newline at end of file +#endif