Add a backtrace function and library detection.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/12/head
Slávek Banko 3 years ago
parent f4582480b4
commit cf63191672
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -5,3 +5,9 @@
// kbabeldict/modules/dbsearchengine
#cmakedefine USE_DB_H_PATH <@USE_DB_H_PATH@>
/* Define to 1 if GLIBC >= 2.1 compatible backtrace facility exists */
#cmakedefine HAVE_BACKTRACE 1
#ifdef HAVE_BACKTRACE
#define BACKTRACE_H <@Backtrace_HEADER@>
#endif

@ -12,6 +12,7 @@
include_directories(
${TDE_INCLUDE_DIR}
${TQT_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)
link_directories(
@ -21,6 +22,11 @@ link_directories(
set( LD_FLAGS "-Wl,-Bstatic -liberty -Wl,-Bdynamic" )
##### configure checks ##########################
include( ConfigureChecks.cmake )
##### other data ################################
configure_file( kminspector.cmake kminspector @ONLY )
@ -48,7 +54,7 @@ tde_add_library( ktrace_s STATIC
tde_add_library( ktrace SHARED
SOURCES ksotrace.cpp ktrace.c
LINK dl
LINK ${DL_LIBRARIES} ${Backtrace_LIBRARY}
DESTINATION ${LIB_INSTALL_DIR}/kmtrace
)

@ -0,0 +1,18 @@
##### check if GLIBC >= 2.1 compatible backtrace facility exists
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 CACHE INTERNAL "" )
endif ()
endif ()
if( NOT HAVE_BACKTRACE )
tde_message_fatal( "bactrace function is required but not available on your system")
endif()

@ -25,6 +25,10 @@
or (US mail) as Mike Haertel c/o Free Software Foundation.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define MALLOC_HOOKS
#define _GNU_SOURCE
@ -35,8 +39,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <execinfo.h>
#include <unistd.h>
#include BACKTRACE_H
#ifdef USE_IN_LIBIO
# include <libio/iolibio.h>

Loading…
Cancel
Save