blob: a791a40dbc1756c512b4253079c5711a7a08dee5 [file] [log] [blame]
Andrew Geissler6aa7eec2023-03-03 12:41:14 -06001From 19d00c15710840910a7397252c14d612746631fe Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 8 Mar 2021 14:58:40 -0800
4Subject: [PATCH] Link libexecinfo if its found, this is needed for musl based
5 systems
Andrew Geissler32b11992021-03-31 13:37:05 -05006
7Fixes
8ld: libglog.so.0.4.0: undefined reference to `backtrace'
9| collect2: error: ld returned 1 exit status
10
11Upstream-Status: Pending
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060013
14---
15 CMakeLists.txt | 5 +++++
16 1 file changed, 5 insertions(+)
17
18diff --git a/CMakeLists.txt b/CMakeLists.txt
19index 846b444..1553358 100644
Andrew Geissler32b11992021-03-31 13:37:05 -050020--- a/CMakeLists.txt
21+++ b/CMakeLists.txt
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060022@@ -162,6 +162,7 @@ cmake_pop_check_state ()
23 check_cxx_symbol_exists (snprintf cstdio HAVE_SNPRINTF)
Andrew Geissler32b11992021-03-31 13:37:05 -050024
25 check_library_exists (dbghelp UnDecorateSymbolName "" HAVE_DBGHELP)
26+check_library_exists (execinfo backtrace "" HAVE_EXECINFO)
27
Andrew Geissler69721092021-07-23 12:57:00 -040028 check_cxx_source_compiles ("
29 #include <cstdlib>
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060030@@ -629,6 +630,10 @@ if (Unwind_FOUND)
Andrew Geissler69721092021-07-23 12:57:00 -040031 set (Unwind_DEPENDENCY "find_dependency (Unwind ${Unwind_VERSION})")
32 endif (Unwind_FOUND)
Andrew Geissler32b11992021-03-31 13:37:05 -050033
34+if (HAVE_EXECINFO)
35+ target_link_libraries (glog PUBLIC execinfo)
36+endif (HAVE_EXECINFO)
37+
38 if (HAVE_DBGHELP)
Andrew Geissler6aa7eec2023-03-03 12:41:14 -060039 target_link_libraries (glog PRIVATE dbghelp)
40 set (glog_libraries_options_for_static_linking "${glog_libraries_options_for_static_linking} -ldbghelp")