Fix build if libbacktrace is not installed, update README

set(CMAKE_REQUIRED_LIBRARIES backtrace) tells our custom libbacktrace
availability check that it needs to link against libbacktrace.
Seems like it also tells other unrelated compiler-checks like for
-fvisibility=hidden to link against libbacktrace, so if it's not
available they fail as well.
Fixed by unsetting CMAKE_REQUIRED_LIBRARIES after the backtrace check.

While debian-based distros ship libbacktrace as part of libgcc,
apparently in Arch Linux and openSUSE (and possibly others) it's a
separate package, so I mantion it in the README as an (optional)
dependency now and made CMake print a warning if it's not found.
This commit is contained in:
Daniel Gibson 2021-06-03 01:38:17 +02:00
parent 2521c3dfdb
commit 1aedbe7dd8
2 changed files with 8 additions and 1 deletions

View file

@ -71,6 +71,10 @@ Required libraries are not part of the tree. These are:
- OpenAL (OpenAL Soft required, Creative's and Apple's versions are made of fail)
- SDL v1.2 or 2.0 (2.0 recommended)
- libcurl (optional, required for server downloads)
- Optionally, on non-Windows: libbacktrace
- sometimes (e.g. on debian-based distros like Ubuntu) it's part of libgcc (=> always available),
sometimes (e.g. Arch Linux, openSUSE) it's in a separate package
- If this is available, dhewm3 prints more useful backtraces if it crashes
- Also, if you're not building recent dhewm3 code from git (but 1.5.1 or older):
- libjpeg (v8)
- libogg, libvorbis, libvorbisfile (may be part of libvorbis)

View file

@ -185,7 +185,7 @@ if(CURL_FOUND)
set(ID_ENABLE_CURL ON)
include_directories(${CURL_INCLUDE_DIR})
else()
message(STATUS "libcurl not found, server downloads won't be available")
message(WARNING "libcurl not found, server downloads won't be available (apart from that dhewm3 will work)")
set(ID_ENABLE_CURL OFF)
set(CURL_LIBRARY "")
endif()
@ -207,11 +207,14 @@ if(NOT WIN32)
set(CMAKE_REQUIRED_LIBRARIES backtrace)
check_c_source_compiles( "#include <backtrace.h>
int main() { backtrace_create_state(NULL, 0, NULL, NULL); return 0; }" HAVE_LIBBACKTRACE )
unset(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_LIBBACKTRACE)
set(sys_libs ${sys_libs} backtrace)
add_definitions(-DD3_HAVE_LIBBACKTRACE)
message(STATUS "Using libbacktrace")
else()
message(WARNING "libbacktrace wasn't found. It's not required but recommended, because it provides useful backtraces if dhewm3 crashes")
endif()
endif() # NOT WIN32