Couldn't add llhttp as dependency with cmake
vdm4k opened this issue · comments
I've tried to use llhttp as dependency for my project and follow this instruction -
FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/archive/refs/tags/v6.0.5.tar.gz") # Using version 6.0.5
FetchContent_MakeAvailable(llhttp)
target_link_libraries(${EXAMPLE_PROJECT_NAME} ${PROJECT_LIBRARIES} llhttp ${PROJECT_NAME})
But it doesn't work
The problem is that project didn't propagate headers folder. -
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include )
I've modified it to -
target_include_directories(${target} SYSTEM PUBLIC $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include> )
And now it works good
PS also maybe this will be better
target_include_directories(${target} SYSTEM PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> PRIVATE ${CMAKE_CURRENT_BINARY_DIR} )
Hi @vdm4k!
First of all, sorry for the very late reply.
You were right, it was not working properly.
I created #226 with a different fix (to minimize changes) and it seems to work for me.
Can you please verify it works for you as well?
My setup, for a single file C executable was the following:
cmake_minimum_required(VERSION 3.24)
project(llhttp-test)
include(FetchContent)
FetchContent_Declare(llhttp URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
FetchContent_MakeAvailable(llhttp)
add_executable(llhttp-test main.c)
target_link_libraries(llhttp-test llhttp_shared)
Once you clear this out, I'll merge and release.
Hi @ShogunPanda !
I've checked your PR and it works great!
Thank you for your fix!