mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-12-19 17:37:42 -05:00
build: fix Descent3 program link failure
In case httplibConfig.cmake is absent, there is still a link failure
because -lcpp-httplib appears nowhere on the command-line.
```
/usr/include/c++/14/bits/unique_ptr.h:1077:(.text+0x7ae9): undefined reference to `httplib::Client::Client(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/lib64/gcc/x86_64-suse-linux/14/../../../../x86_64-suse-linux/bin/ld: /usr/include/c++/14/bits/unique_ptr.h:93:(.text+0x7b0b): undefined reference to `httplib::Client::~Client()'
```
A header is not enough to get the build job done.
But… it turns out cpp-httplib can either be built as a classic
header + library combo, or installed in a header-only fashion. *sigh*
Deal with it.
Fixes: 88e487c724
This commit is contained in:
@@ -186,9 +186,16 @@ if (TARGET httplib::httplib)
|
||||
else()
|
||||
# Some Linux distributions do not package httplibConfig.cmake, so find the header manually
|
||||
find_file(CPP_HTTPLIB_HEADER httplib.h REQUIRED)
|
||||
find_library(CPP_HTTPLIB_LIB cpp-httplib QUIET)
|
||||
|
||||
# The target httplib::httplib cannot be created manually, so rename it
|
||||
add_library(httplib INTERFACE ${CPP_HTTPLIB_HEADER})
|
||||
|
||||
# And some Linux distributions build httplib as header-only,
|
||||
# and some as header+library. What a mess!
|
||||
if (NOT ${CPP_HTTPLIB_LIB} STREQUAL "CPP_HTTPLIB_LIB-NOTFOUND")
|
||||
target_link_libraries(httplib INTERFACE ${CPP_HTTPLIB_LIB})
|
||||
endif ()
|
||||
endif()
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(plog REQUIRED)
|
||||
|
||||
Reference in New Issue
Block a user