summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOBATA Akio <obache@wizdas.com>2020-08-16 18:15:33 +0900
committerSlávek Banko <slavek.banko@axis.cz>2021-02-03 22:37:07 +0100
commit3241cab0cf421f41c6872f3212d3b80375612757 (patch)
treedeb0dca8907cf1c897dd5cf0b868b081b32015c2
parent75aaa51fe2d63a0258522ca44b88215093893c6e (diff)
downloadtdelibs-3241cab0cf421f41c6872f3212d3b80375612757.tar.gz
tdelibs-3241cab0cf421f41c6872f3212d3b80375612757.zip
Allow to use backtrace(3) external library for kdebug
Signed-off-by: OBATA Akio <obache@wizdas.com> (cherry picked from commit 2167207adc49b498536a5a8533c27fc67e0c6e9c)
-rw-r--r--CMakeLists.txt13
-rw-r--r--config.h.cmake5
-rw-r--r--kdecore/kdebug.cpp6
3 files changed, 21 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1252f8461..621382177 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -317,7 +317,18 @@ check_symbol_exists( gethostbyname2_r "netdb.h" HAVE_GETHOSTBYNAME2_R )
check_symbol_exists( gethostbyname_r "netdb.h" HAVE_GETHOSTBYNAME_R )
check_symbol_exists( gai_strerror "sys/types.h;sys/socket.h;netdb.h" HAVE_GAI_STRERROR )
check_symbol_exists( getaddrinfo "sys/types.h;sys/socket.h;netdb.h" HAVE_GETADDRINFO )
-check_symbol_exists( backtrace "execinfo.h" HAVE_BACKTRACE )
+if ( CMAKE_MAJOR_VERSION LESS "3" )
+ check_symbol_exists( backtrace "execinfo.h" HAVE_BACKTRACE )
+ if ( HAVE_BACKTRACE )
+ set ( Backtrace_LIBRARY "" )
+ set ( Backtrace_HEADER "execinfo.h" )
+ endif ()
+else ()
+ find_package( Backtrace )
+ if ( Backtrace_FOUND )
+ set ( HAVE_BACKTRACE 1 )
+ endif ()
+endif ()
check_cxx_source_compiles( "#include <cxxabi.h>
int main() { abi::__cxa_demangle(0, 0, 0, 0); return 0; }"
HAVE_ABI_CXA_DEMANGLE )
diff --git a/config.h.cmake b/config.h.cmake
index 32e8c8298..5b73a07de 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -66,8 +66,11 @@
/* Define if you have strvercmp prototype */
#cmakedefine HAVE_STRVERCMP_PROTO 1
-/* Define to 1 if execinfo.h exists and defines backtrace (GLIBC >= 2.1) */
+/* Define to 1 if GLIBC >= 2.1 compatible backtrace facility exists */
#cmakedefine HAVE_BACKTRACE 1
+#ifdef HAVE_BACKTRACE
+#define BACKTRACE_H <@Backtrace_HEADER@>
+#endif
/* Define to 1 if gcc (or may be some over compiller) provides abi::__cxa_demangle() */
#cmakedefine HAVE_ABI_CXA_DEMANGLE 1
diff --git a/kdecore/kdebug.cpp b/kdecore/kdebug.cpp
index 17cb95842..82fb7b24c 100644
--- a/kdecore/kdebug.cpp
+++ b/kdecore/kdebug.cpp
@@ -59,7 +59,11 @@
#include <config.h>
#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
+#include BACKTRACE_H
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
#ifdef HAVE_ABI_CXA_DEMANGLE
#include <cxxabi.h>