Skip to content

Commit b671ac1

Browse files
tom-seddonUzlopak
andauthored
build: add llhttp-specific prefix to CMake options. (#657)
* 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 #647 * modify docs --------- Co-authored-by: Tom Seddon <tom@> Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com>
1 parent a1ec671 commit b671ac1

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ endif()
2424
# Options
2525
#
2626
# Generic option
27-
option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so)" ON)
28-
option(BUILD_STATIC_LIBS "Build static libraries (.lib/.a)" OFF)
27+
option(LLHTTP_BUILD_SHARED_LIBS "Build shared libraries (.dll/.so)" ON)
28+
option(LLHTTP_BUILD_STATIC_LIBS "Build static libraries (.lib/.a)" OFF)
2929

3030
# Source code
3131
set(LLHTTP_SOURCES
@@ -80,19 +80,19 @@ function(config_library target)
8080
)
8181
endfunction(config_library target)
8282

83-
if(BUILD_SHARED_LIBS)
83+
if(LLHTTP_BUILD_SHARED_LIBS)
8484
add_library(llhttp_shared SHARED
8585
${llhttp_src}
8686
)
8787
add_library(llhttp::llhttp ALIAS llhttp_shared)
8888
config_library(llhttp_shared)
8989
endif()
9090

91-
if(BUILD_STATIC_LIBS)
91+
if(LLHTTP_BUILD_STATIC_LIBS)
9292
add_library(llhttp_static STATIC
9393
${llhttp_src}
9494
)
95-
if(NOT BUILD_SHARED_LIBS)
95+
if(NOT LLHTTP_BUILD_SHARED_LIBS)
9696
add_library(llhttp::llhttp ALIAS llhttp_static)
9797
endif()
9898
config_library(llhttp_static)
@@ -111,6 +111,6 @@ message(STATUS "Project configure summary:")
111111
message(STATUS "")
112112
message(STATUS " CMake build type .................: ${CMAKE_BUILD_TYPE}")
113113
message(STATUS " Install prefix ...................: ${CMAKE_INSTALL_PREFIX}")
114-
message(STATUS " Build shared library .............: ${BUILD_SHARED_LIBS}")
115-
message(STATUS " Build static library .............: ${BUILD_STATIC_LIBS}")
114+
message(STATUS " Build shared library .............: ${LLHTTP_BUILD_SHARED_LIBS}")
115+
message(STATUS " Build static library .............: ${LLHTTP_BUILD_STATIC_LIBS}")
116116
message(STATUS "")

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,16 @@ If you want to use this library in a CMake project as a static library, you can
435435
FetchContent_Declare(llhttp
436436
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
437437
438-
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
439-
set(BUILD_STATIC_LIBS ON CACHE INTERNAL "")
438+
set(LLHTTP_BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
439+
set(LLHTTP_BUILD_STATIC_LIBS ON CACHE INTERNAL "")
440440
FetchContent_MakeAvailable(llhttp)
441441
442442
# Link with the llhttp_static target
443443
target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp_static ${PROJECT_NAME})
444444
```
445445

446+
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.
447+
446448
_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._
447449

448450
## Building on Windows

0 commit comments

Comments
 (0)