diff --git a/CMakeLists.txt b/CMakeLists.txt index 008f97df..c95ee8bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,11 +103,21 @@ find_package(OpenGL REQUIRED) list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR}) list(APPEND yquake2OpenGLLinkerFlags ${OPENGL_LIBRARIES}) -# FreeBSD needs libexecinfo. -if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD") - find_library(EXECINFO_LIBRARIES execinfo /usr/lib /usr/local/lib) - list(APPEND yquake2ClientLinkerFlags ${EXECINFO_LIBRARIES}) - list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES}) +# backtrace lookup +# Some systems like Linux has it within the libc some like the BSD, Haiku ... +# into an external libexecinfo library +include(CheckFunctionExists) +include(CheckLibraryExists) +check_function_exists(backtrace HAVE_EXECINFO_SYS) +IF (NOT HAVE_EXECINFO_SYS) + check_library_exists(execinfo backtrace "" HAVE_EXECINFO_LIB) + if (HAVE_EXECINFO_LIB) + list(APPEND yquake2ClientLinkerFlags execinfo) + list(APPEND yquake2ServerLinkerFlags execinfo) + add_definitions(-DHAVE_EXECINFO) + endif() +else() + add_definitions(-DHAVE_EXECINFO) endif() # cURL support. diff --git a/src/backends/unix/signalhandler.c b/src/backends/unix/signalhandler.c index ee015575..e0805e3a 100644 --- a/src/backends/unix/signalhandler.c +++ b/src/backends/unix/signalhandler.c @@ -30,7 +30,7 @@ #include "../../common/header/common.h" -#if defined(__GLIBC__) || defined(__FreeBSD__) || defined(__APPLE__) +#if defined(HAVE_EXECINFO) #include void