Skip to content

Commit 86dde50

Browse files
committed
added detection of execinfo.h to CMake / prefer HAVE_EXECINFO_H instead of platform checks in config.h
1 parent f0209f2 commit 86dde50

6 files changed

Lines changed: 23 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include(cmake/compilerCheck.cmake)
1717
include(cmake/versions.cmake)
1818
include(cmake/findDependencies.cmake)
1919
include(cmake/compileroptions.cmake)
20+
include(cmake/includechecks.cmake)
2021
include(cmake/compilerDefinitions.cmake)
2122
include(cmake/buildFiles.cmake)
2223
if(BUILD_GUI)

cli/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
file(GLOB hdrs "*.h")
32
file(GLOB srcs "*.cpp")
43
file(GLOB mainfile "main.cpp")

cmake/compilerDefinitions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ if(NO_WINDOWS_SEH)
6666
add_definitions(-DNO_WINDOWS_SEH)
6767
endif()
6868

69+
if(NOT MSVC)
70+
add_definitions(-DHAVE_EXECINFO_H=${HAVE_EXECINFO_H})
71+
endif()
72+
6973
if(FILESDIR_DEF)
7074
file(TO_CMAKE_PATH "${FILESDIR_DEF}" _filesdir)
7175
add_definitions(-DFILESDIR="${_filesdir}")

cmake/includechecks.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
include(CheckIncludeFileCXX)
2+
3+
if(NOT MSVC)
4+
check_include_file_cxx(execinfo.h HAVE_EXECINFO_H)
5+
if(NOT HAVE_EXECINFO_H)
6+
set(HAVE_EXECINFO_H 0)
7+
endif()
8+
endif()

cmake/printInfo.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ message(STATUS "C++ flags (RelWithDebInfo) = ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
1515
message(STATUS "C++ flags (Debug) = ${CMAKE_CXX_FLAGS_DEBUG}")
1616
message(STATUS "CMAKE_EXE_LINKER_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}")
1717
message(STATUS "CPPCHK_GLIBCXX_DEBUG = ${CPPCHK_GLIBCXX_DEBUG}")
18+
if(DEFINED HAVE_EXECINFO_H)
19+
message(STATUS "HAVE_EXECINFO_H = ${HAVE_EXECINFO_H}")
20+
endif()
1821
get_directory_property(DirCompileDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
1922
message(STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}")
2023
get_directory_property(DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS)

lib/config.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,15 @@
206206
#define USE_WINDOWS_SEH
207207
#endif
208208

209-
#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
209+
#if !defined(NO_UNIX_BACKTRACE_SUPPORT)
210+
#if defined(HAVE_EXECINFO_H)
211+
#if HAVE_EXECINFO_H
210212
#define USE_UNIX_BACKTRACE_SUPPORT
211213
#endif
214+
#elif defined(__GNUC__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__SVR4) && !defined(__QNX__) && !defined(_AIX)
215+
#define USE_UNIX_BACKTRACE_SUPPORT
216+
#endif
217+
#endif
212218

213219
#if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__OS2__)
214220
#define USE_UNIX_SIGNAL_HANDLING

0 commit comments

Comments
 (0)