You can integrate llhttp into a CMake project using FetchContent. Note that you should use a release tarball URL rather than a git repository URL to ensure CMakeLists.txt string replacements work correctly.
As a Shared Library
Link against the llhttp_shared target.
As a Static Library
Set LLHTTP_BUILD_SHARED_LIBS to OFF and LLHTTP_BUILD_STATIC_LIBS to ON before calling FetchContent_MakeAvailable. Link against the llhttp_static target.
Note: For versions prior to 9.3.0, use BUILD_SHARED_LIBS and BUILD_STATIC_LIBS instead of the LLHTTP_ prefixed versions.
### Shared Library
```cmake
FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
FetchContent_MakeAvailable(llhttp)
# Link with the llhttp_shared target
target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp_shared ${PROJECT_NAME})
Static Library
FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
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})