This line seems off. Typically the way you link an external library is by first finding the files with find_package
, then linking the target like target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
. For Curl specifically, there also seems to be an official FindCURL module.
My guess is that you’d need to write something along the lines of
include(FindCURL)
find_package(CURL REQUIRED)
if (CURL_FOUND)
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
else()
# fail with a useful message
endif()
I’ve never linked against curl though, so to some extent I’m just guesing based on the documentation.
It’s possible also, if you’re compiling curl yourself with CMake, that you may want to find Curl in a slightly different way using find_package(CURL CONFIG REQUIRED)
. This seems to be what this part of the FindCURL module documentation is suggesting. In which case you may also have to add to your prefix path. Something like
include(FindCURL)
list(APPEND CMAKE_PREFIX_PATH <path>/<to>/<directory-with-CURLConfig.cmake>)
find_package(CURL CONFIG REQUIRED)
Also note, that instead of
include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/curl/include)
you’d probably want to write
include_directories(${PROJECT_NAME} PUBLIC ${CURL_INCLUDE_DIRS})