use CMake's FindBacktrace for backtrace feature detection

master
robotanarchy 9 years ago
parent 3dd2393797
commit 94cac7a014

@ -58,6 +58,14 @@ find_package(Pango)
find_package(GdkPixbuf) find_package(GdkPixbuf)
find_package(PAM) find_package(PAM)
find_package(Backtrace)
if(Backtrace_FOUND)
include_directories(${Backtrace_INCLUDE_DIRS})
target_link_libraries(${Backtrace_LIBRARIES})
add_definitions(-DSWAY_Backtrace_FOUND=1)
set(SWAY_Backtrace_HEADER "${Backtrace_HEADER}")
endif()
include(FeatureSummary) include(FeatureSummary)
include(Manpage) include(Manpage)

@ -1,4 +1,5 @@
add_library(sway-common add_library(sway-common
${SWAY_Backtrace_HEADER}
ipc-client.c ipc-client.c
list.c list.c
log.c log.c

@ -10,7 +10,6 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <stringop.h> #include <stringop.h>
#include <execinfo.h>
int colored = 1; int colored = 1;
log_importance_t loglevel_default = L_ERROR; log_importance_t loglevel_default = L_ERROR;
@ -137,6 +136,7 @@ bool _sway_assert(bool condition, const char* format, ...) {
} }
void error_handler(int sig) { void error_handler(int sig) {
#if SWAY_Backtrace_FOUND
int i; int i;
int max_lines = 20; int max_lines = 20;
void *array[max_lines]; void *array[max_lines];
@ -155,5 +155,8 @@ void error_handler(int sig) {
for (i = 0; (size_t)i < bt_len; i++) { for (i = 0; (size_t)i < bt_len; i++) {
sway_log(L_ERROR, "Backtrace: %s", bt[i]); sway_log(L_ERROR, "Backtrace: %s", bt[i]);
} }
#else
sway_log(L_ERROR, "Error: Signal %d.", sig);
#endif
exit(1); exit(1);
} }

Loading…
Cancel
Save