diff --git a/.travis/install-debian.sh b/.travis/install-debian.sh index a4c29bbf..3f1e4388 100755 --- a/.travis/install-debian.sh +++ b/.travis/install-debian.sh @@ -5,6 +5,6 @@ sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo add-apt-repository -y 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main' sudo apt-get update -qq sudo apt-get install -q -y \ - cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev \ + cmake cmake-data libc6-dev libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev \ libgtkmm-3.0-dev libpangomm-1.4-dev libcairo2-dev libgl1-mesa-dev libglu-dev \ libfreetype6-dev dpkg-dev libstdc++-5-dev clang-3.9 clang++-3.9 lcov diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 47ca43a0..fcee2851 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,13 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +set(HAVE_BACKTRACE ${Backtrace_FOUND}) +if(HAVE_BACKTRACE) + set(BACKTRACE_HEADER <${Backtrace_HEADER}>) +endif() + set(HAVE_SPACEWARE ${SPACEWARE_FOUND}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) @@ -75,6 +81,11 @@ include_directories( ${FREETYPE_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS}) +if(Backtrace_FOUND) + include_directories( + ${Backtrace_INCLUDE_DIRS}) +endif() + if(SPACEWARE_FOUND) include_directories( ${SPACEWARE_INCLUDE_DIR}) @@ -208,8 +219,12 @@ target_link_libraries(solvespace-core ${util_LIBRARIES} ${ZLIB_LIBRARY} ${PNG_LIBRARY} - ${FREETYPE_LIBRARY} - ${Backtrace_LIBRARIES}) + ${FREETYPE_LIBRARY}) + +if(Backtrace_FOUND) + target_link_libraries(solvespace-core + ${Backtrace_LIBRARY}) +endif() target_compile_options(solvespace-core PRIVATE ${COVERAGE_FLAGS}) diff --git a/src/config.h.in b/src/config.h.in index 5c680c60..b2ebaef6 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -9,6 +9,11 @@ /* Do we have the si library on win32, or libspnav on *nix? */ #cmakedefine HAVE_SPACEWARE +/* What OpenGL version do we use? */ #define HAVE_OPENGL @OPENGL@ +/* Do we have backtrace() function, and if yes, in which library? */ +#cmakedefine HAVE_BACKTRACE +#define BACKTRACE_HEADER @BACKTRACE_HEADER@ + #endif diff --git a/src/platform/unixutil.cpp b/src/platform/unixutil.cpp index 125623c0..dc4685b2 100644 --- a/src/platform/unixutil.cpp +++ b/src/platform/unixutil.cpp @@ -7,8 +7,11 @@ // Copyright 2008-2013 Jonathan Westhues. // Copyright 2013 Daniel Richard G. //----------------------------------------------------------------------------- -#include +#include "config.h" #include "solvespace.h" +#if defined(HAVE_BACKTRACE) +# include BACKTRACE_HEADER +#endif namespace SolveSpace { @@ -29,7 +32,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 +#if !defined(LIBRARY) && defined(HAVE_BACKTRACE) static void *ptrs[1024] = {}; size_t nptrs = backtrace(ptrs, sizeof(ptrs) / sizeof(ptrs[0])); char **syms = backtrace_symbols(ptrs, nptrs); @@ -44,6 +47,8 @@ void assert_failure(const char *file, unsigned line, const char *function, fprintf(stderr, "%2zu: %p\n", i, ptrs[i]); } } +#else + fprintf(stderr, "Backtrace support not compiled in.\n"); #endif abort();