libstrawberry-common: check for library/includes for backtrace() (#364)
This is a non-standard header, so it should be checked properly. This fixes compilation with musl libc and possibly other C library implementations.
This commit is contained in:
@@ -66,6 +66,7 @@ endif ()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(Threads)
|
||||
find_package(Backtrace)
|
||||
find_package(GnuTLS)
|
||||
find_package(Protobuf REQUIRED)
|
||||
find_library(PROTOBUF_STATIC_LIBRARY libprotobuf.a libprotobuf)
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
if (Backtrace_FOUND)
|
||||
include_directories(${Backtrace_INCLUDE_DIRS})
|
||||
endif (Backtrace_FOUND)
|
||||
|
||||
include_directories(${PROTOBUF_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/backtrace_inc.h.in ${CMAKE_CURRENT_BINARY_DIR}/backtrace_inc.h)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -U__STRICT_ANSI__ -Wall -Wextra -Wpedantic -Woverloaded-virtual -fpermissive")
|
||||
@@ -38,6 +44,10 @@ add_library(libstrawberry-common STATIC
|
||||
${MOC}
|
||||
)
|
||||
|
||||
if (Backtrace_FOUND)
|
||||
target_link_libraries(libstrawberry-common ${Backtrace_LIBRARIES})
|
||||
endif (Backtrace_FOUND)
|
||||
|
||||
target_link_libraries(libstrawberry-common
|
||||
#${PROTOBUF_LIBRARY}
|
||||
${TAGLIB_LIBRARIES}
|
||||
|
||||
25
ext/libstrawberry-common/backtrace_inc.h.in
Normal file
25
ext/libstrawberry-common/backtrace_inc.h.in
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2013, Jonas Kvinge <jonas@strawbs.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#cmakedefine01 Backtrace_FOUND
|
||||
|
||||
#if Backtrace_FOUND
|
||||
# define HAVE_BACKTRACE 1
|
||||
# include <${Backtrace_HEADER}>
|
||||
#endif
|
||||
@@ -14,6 +14,8 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#include "backtrace_inc.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
@@ -32,9 +34,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
@@ -255,7 +254,7 @@ QString DemangleSymbol(const QString &symbol) {
|
||||
}
|
||||
|
||||
void DumpStackTrace() {
|
||||
#ifdef Q_OS_UNIX
|
||||
#ifdef HAVE_BACKTRACE
|
||||
void* callstack[128];
|
||||
int callstack_size = backtrace(reinterpret_cast<void**>(&callstack), sizeof(callstack));
|
||||
char** symbols = backtrace_symbols(reinterpret_cast<void**>(&callstack), callstack_size);
|
||||
|
||||
Reference in New Issue
Block a user