From 71d74d47f8dc21a01437b8cff79a22ddbef0675a Mon Sep 17 00:00:00 2001 From: Tom Seddon Date: Wed, 23 Apr 2025 19:57:51 +0100 Subject: [PATCH 1/2] build: add llhttp-specific prefix to CMake options. BUILD_SHARED_LIBS is now called LLHTTP_BUILD_SHARED_LIBS. BUILD_STATIC_LIBS is now called LLHTTP_BUILD_STATIC_LIBS. CMake options have global scope so there's the risk of conflict otherwise. For example, libcurl has a BUILD_STATIC_LIBS option too. Documentation updates to be discussed. See https://github.com/nodejs/llhttp/issues/647 --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fb106aa..251b0845 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,8 @@ endif() # Options # # Generic option -option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so)" ON) -option(BUILD_STATIC_LIBS "Build static libraries (.lib/.a)" OFF) +option(LLHTTP_BUILD_SHARED_LIBS "Build shared libraries (.dll/.so)" ON) +option(LLHTTP_BUILD_STATIC_LIBS "Build static libraries (.lib/.a)" OFF) # Source code set(LLHTTP_SOURCES @@ -80,7 +80,7 @@ function(config_library target) ) endfunction(config_library target) -if(BUILD_SHARED_LIBS) +if(LLHTTP_BUILD_SHARED_LIBS) add_library(llhttp_shared SHARED ${llhttp_src} ) @@ -88,11 +88,11 @@ if(BUILD_SHARED_LIBS) config_library(llhttp_shared) endif() -if(BUILD_STATIC_LIBS) +if(LLHTTP_BUILD_STATIC_LIBS) add_library(llhttp_static STATIC ${llhttp_src} ) - if(BUILD_SHARED_LIBS) + if(LLHTTP_BUILD_SHARED_LIBS) add_library(llhttp::llhttp ALIAS llhttp_shared) else() add_library(llhttp::llhttp ALIAS llhttp_static) @@ -113,6 +113,6 @@ message(STATUS "Project configure summary:") message(STATUS "") message(STATUS " CMake build type .................: ${CMAKE_BUILD_TYPE}") message(STATUS " Install prefix ...................: ${CMAKE_INSTALL_PREFIX}") -message(STATUS " Build shared library .............: ${BUILD_SHARED_LIBS}") -message(STATUS " Build static library .............: ${BUILD_STATIC_LIBS}") +message(STATUS " Build shared library .............: ${LLHTTP_BUILD_SHARED_LIBS}") +message(STATUS " Build static library .............: ${LLHTTP_BUILD_STATIC_LIBS}") message(STATUS "") From ea8234e3330a03252bacfc4735ecd649e6dbbd32 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sun, 1 Jun 2025 10:46:41 +0200 Subject: [PATCH 2/2] modify docs --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70af44ff..008b7e62 100644 --- a/README.md +++ b/README.md @@ -435,14 +435,16 @@ If you want to use this library in a CMake project as a static library, you can FetchContent_Declare(llhttp URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz") -set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") -set(BUILD_STATIC_LIBS ON CACHE INTERNAL "") +set(LLHTTP_BUILD_SHARED_LIBS OFF CACHE INTERNAL "") +set(LLHTTP_BUILD_STATIC_LIBS ON CACHE INTERNAL "") FetchContent_MakeAvailable(llhttp) # Link with the llhttp_static target target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp_static ${PROJECT_NAME}) ``` +If using a version prior to 9.3.0, the `LLHTTP_BUILD_SHARED_LIBS` and `LLHTTP_BUILD_STATIC_LIBS` options are known as `BUILD_SHARED_LIBS` and `BUILD_STATIC_LIBS` and should be used instead. + _Note that using the git repo directly (e.g., via a git repo url and tag) will not work with FetchContent_Declare because [CMakeLists.txt](./CMakeLists.txt) requires string replacements (e.g., `_RELEASE_`) before it will build._ ## Building on Windows