Use a more rigorous check for library containing backtrace().

pull/200/merge
whitequark 2018-07-11 02:14:39 +00:00
parent 8cedefc278
commit 49ff36fd51
4 changed files with 30 additions and 5 deletions

View File

@ -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 add-apt-repository -y 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main'
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install -q -y \ 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 \ 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 libfreetype6-dev dpkg-dev libstdc++-5-dev clang-3.9 clang++-3.9 lcov

View File

@ -6,7 +6,13 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}) ${CMAKE_CURRENT_BINARY_DIR})
set(HAVE_BACKTRACE ${Backtrace_FOUND})
if(HAVE_BACKTRACE)
set(BACKTRACE_HEADER <${Backtrace_HEADER}>)
endif()
set(HAVE_SPACEWARE ${SPACEWARE_FOUND}) set(HAVE_SPACEWARE ${SPACEWARE_FOUND})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h) ${CMAKE_CURRENT_BINARY_DIR}/config.h)
@ -75,6 +81,11 @@ include_directories(
${FREETYPE_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}) ${CAIRO_INCLUDE_DIRS})
if(Backtrace_FOUND)
include_directories(
${Backtrace_INCLUDE_DIRS})
endif()
if(SPACEWARE_FOUND) if(SPACEWARE_FOUND)
include_directories( include_directories(
${SPACEWARE_INCLUDE_DIR}) ${SPACEWARE_INCLUDE_DIR})
@ -208,8 +219,12 @@ target_link_libraries(solvespace-core
${util_LIBRARIES} ${util_LIBRARIES}
${ZLIB_LIBRARY} ${ZLIB_LIBRARY}
${PNG_LIBRARY} ${PNG_LIBRARY}
${FREETYPE_LIBRARY} ${FREETYPE_LIBRARY})
${Backtrace_LIBRARIES})
if(Backtrace_FOUND)
target_link_libraries(solvespace-core
${Backtrace_LIBRARY})
endif()
target_compile_options(solvespace-core target_compile_options(solvespace-core
PRIVATE ${COVERAGE_FLAGS}) PRIVATE ${COVERAGE_FLAGS})

View File

@ -9,6 +9,11 @@
/* Do we have the si library on win32, or libspnav on *nix? */ /* Do we have the si library on win32, or libspnav on *nix? */
#cmakedefine HAVE_SPACEWARE #cmakedefine HAVE_SPACEWARE
/* What OpenGL version do we use? */
#define HAVE_OPENGL @OPENGL@ #define HAVE_OPENGL @OPENGL@
/* Do we have backtrace() function, and if yes, in which library? */
#cmakedefine HAVE_BACKTRACE
#define BACKTRACE_HEADER @BACKTRACE_HEADER@
#endif #endif

View File

@ -7,8 +7,11 @@
// Copyright 2008-2013 Jonathan Westhues. // Copyright 2008-2013 Jonathan Westhues.
// Copyright 2013 Daniel Richard G. <skunk@iSKUNK.ORG> // Copyright 2013 Daniel Richard G. <skunk@iSKUNK.ORG>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <execinfo.h> #include "config.h"
#include "solvespace.h" #include "solvespace.h"
#if defined(HAVE_BACKTRACE)
# include BACKTRACE_HEADER
#endif
namespace SolveSpace { 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, "File %s, line %u, function %s:\n", file, line, function);
fprintf(stderr, "Assertion '%s' failed: ((%s) == false).\n", message, condition); fprintf(stderr, "Assertion '%s' failed: ((%s) == false).\n", message, condition);
#ifndef LIBRARY #if !defined(LIBRARY) && defined(HAVE_BACKTRACE)
static void *ptrs[1024] = {}; static void *ptrs[1024] = {};
size_t nptrs = backtrace(ptrs, sizeof(ptrs) / sizeof(ptrs[0])); size_t nptrs = backtrace(ptrs, sizeof(ptrs) / sizeof(ptrs[0]));
char **syms = backtrace_symbols(ptrs, nptrs); 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]); fprintf(stderr, "%2zu: %p\n", i, ptrs[i]);
} }
} }
#else
fprintf(stderr, "Backtrace support not compiled in.\n");
#endif #endif
abort(); abort();