From 93538e89c69c396c136c84e7f802d142bcb8dfbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <> Date: Sat, 16 Aug 2025 18:49:16 -0400 Subject: [PATCH] build/cmake: add appropriate llhttp flags to opendht.pc --- CMakeLists.txt | 13 ++++++++++++- opendht.pc.in | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cf8a546..174c5a5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 () diff --git a/opendht.pc.in b/opendht.pc.in index 63de4294..ef579883 100644 --- a/opendht.pc.in +++ b/opendht.pc.in @@ -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}