diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c6129cb..870b87be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)