From 5fc855e5195e10a93f2db76deee89b99d8841e36 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 20 Mar 2023 01:36:49 +1000 Subject: [PATCH] CMake: Add libbacktrace module --- cmake/FindLibbacktrace.cmake | 31 +++++++++++++++++++++++++++++++ cmake/SearchForStuff.cmake | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 cmake/FindLibbacktrace.cmake diff --git a/cmake/FindLibbacktrace.cmake b/cmake/FindLibbacktrace.cmake new file mode 100644 index 0000000000..930504a783 --- /dev/null +++ b/cmake/FindLibbacktrace.cmake @@ -0,0 +1,31 @@ +# - Try to find libbacktrace +# Once done this will define +# LIBBACKTRACE_FOUND - System has libbacktrace +# LIBBACKTRACE_INCLUDE_DIRS - The libbacktrace include directories +# LIBBACKTRACE_LIBRARIES - The libraries needed to use libbacktrace + +FIND_PATH( + LIBBACKTRACE_INCLUDE_DIR backtrace.h + HINTS /usr/include /usr/local/include + ${LIBBACKTRACE_PATH_INCLUDES} +) + +FIND_LIBRARY( + LIBBACKTRACE_LIBRARY + NAMES backtrace + PATHS ${ADDITIONAL_LIBRARY_PATHS} ${LIBBACKTRACE_PATH_LIB} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libbacktrace DEFAULT_MSG + LIBBACKTRACE_LIBRARY LIBBACKTRACE_INCLUDE_DIR) + +if(LIBBACKTRACE_FOUND) + add_library(libbacktrace::libbacktrace UNKNOWN IMPORTED) + set_target_properties(libbacktrace::libbacktrace PROPERTIES + IMPORTED_LOCATION ${LIBBACKTRACE_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${LIBBACKTRACE_INCLUDE_DIR} + ) +endif() + +mark_as_advanced(LIBBACKTRACE_INCLUDE_DIR LIBBACKTRACE_LIBRARY) diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index ea84fd65cc..6b8ddf5c32 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -86,6 +86,8 @@ else() if(WAYLAND_API) find_package(Wayland REQUIRED) endif() + + find_package(Libbacktrace) endif() endif(WIN32)