Unix: compatibility with platforms where backtrace() is not in libc.

Also, don't depend on backtrace() when built as libslvs; it is not
the responsbility of the library to use it.
pull/33/head
whitequark 2016-07-19 15:40:52 +00:00
parent 8ccc9fe56c
commit ad2371cfae
3 changed files with 8 additions and 0 deletions

View File

@ -187,6 +187,7 @@ elseif(APPLE)
find_package(Freetype REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
else() # Linux and compatible systems
find_package(Backtrace)
find_package(SpaceWare)
# Use freedesktop's pkg-config to locate everything.

View File

@ -216,6 +216,11 @@ if(SPACEWARE_FOUND)
${SPACEWARE_LIBRARIES})
endif()
if(Backtrace_FOUND)
target_link_libraries(solvespace
${Backtrace_LIBRARIES})
endif()
if(APPLE)
foreach(lib ${platform_BUNDLED_LIBS})
get_filename_component(name ${lib} NAME)

View File

@ -31,6 +31,7 @@ void assert_failure(const char *file, unsigned line, const char *function,
fprintf(stderr, "File %s, line %u, function %s:\n", file, line, function);
fprintf(stderr, "Assertion '%s' failed: ((%s) == false).\n", message, condition);
#ifndef LIBRARY
static void *ptrs[1024] = {};
size_t nptrs = backtrace(ptrs, sizeof(ptrs) / sizeof(ptrs[0]));
char **syms = backtrace_symbols(ptrs, nptrs);
@ -45,6 +46,7 @@ void assert_failure(const char *file, unsigned line, const char *function,
fprintf(stderr, "%2zu: %p\n", i, ptrs[i]);
}
}
#endif
abort();
}