build/cmake: add appropriate llhttp flags to opendht.pc

This commit is contained in:
Adrien Béraud authored and Adrien Béraud committed 2025-08-16 21:22:57 -04:00
1 parent 947e845dcd
commit 93538e89c6
2 files changed
+13 -2

No files matched your search

+12 -1
View File
@@ -105,6 +105,9 @@ endif ()
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if (NOT MSVC)
# Initialize pkg-config substitution variables for llhttp before any detection
set(http_lib "")
set(llhttp_lib "")
# Generalized UNIX/MSYS2 build pipeline
set (THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package (Threads)
@@ -153,8 +156,9 @@ if (NOT MSVC)
if (OPENDHT_HTTP)
pkg_search_module(LLHTTP IMPORTED_TARGET llhttp libllhttp)
if (LLHTTP_FOUND)
message(STATUS "Found llhttp: ${LLHTTP_FOUND} ${LLHTTP_INCLUDE_DIR}")
message(STATUS "Found llhttp: ${LLHTTP_FOUND} ${LLHTTP_INCLUDE_DIR} (module: ${LLHTTP_MODULE_NAME})")
set(llhttp_target PkgConfig::LLHTTP)
set(llhttp_lib ", ${LLHTTP_MODULE_NAME}")
else()
message(STATUS "llhttp not found with pkgconfig")
endif()
@@ -196,6 +200,7 @@ if (NOT MSVC)
if (OPENDHT_HTTP)
find_package(llhttp CONFIG REQUIRED)
set(llhttp_target llhttp::llhttp_static)
set(http_lib "-lllhttp")
if (OPENDHT_PROXY_OPENSSL)
find_package(openssl REQUIRED)
endif()
@@ -244,6 +249,9 @@ if (NOT MSVC)
INTERFACE_INCLUDE_DIRECTORIES ${LLHTTP_INCLUDE_DIR}
)
set(llhttp_target llhttp_static)
if (NOT llhttp_lib)
set(http_lib "-lllhttp")
endif()
elseif (OPENDHT_DOWNLOAD_DEPS)
message(STATUS "Fallback mode specified, downloading llhttp")
FetchContent_Declare(llhttp-local REQUIRED
@@ -263,6 +271,9 @@ if (NOT MSVC)
else()
set(llhttp_target llhttp_static)
endif()
if (NOT llhttp_lib)
set(http_lib "-lllhttp")
endif()
else()
message(SEND_ERROR "llhttp not found and fallback downloader disabled. Install llhttp or use OPENDHT_DOWNLOAD_DEPS option")
endif ()
+1 -1
View File
@@ -8,5 +8,5 @@ Version: @VERSION@
Libs: -L${libdir} -lopendht
Libs.private: @http_lib@ -pthread
Requires: gnutls >= 3.3@jsoncpp_lib@@openssl_lib@
Requires.private: nettle >= 2.4@argon2_lib@@iouring_lib@
Requires.private: nettle >= 2.4@argon2_lib@@llhttp_lib@@iouring_lib@
Cflags: -I${includedir}