I’m trying to link curlcpp, a C++ curl wrapper, to a library of my own.
My idea was to:
- FetchContent_Declare both curl and curlcpp.
- FetchContent_MakeAvailable both of them as well.
- Link libcurl.lib and curlcpp lib to my library.
I’m getting though an error saying that curlcpp needs CURL_LIBRARY
variable to be set.
- Is there any way to 1) set
CURL_LIBRARY
to wherever the build process is going to leave libcurl.lib, and 2) have it available for curlcpp compilation? I understand aset(CURL_LIBRARY <path to libcurl.lib>)
should suffice. - I know curl sources are downloaded to
${curl_SOURCE_DIR}
. Can I know where the output libcurl.lib will be placed? Is there a${curl_BINARY_DIR}
?
Here’s what I understand can be the relevant code from my CMakeLists.txt files.
cmake_minimum_required(VERSION 3.5)
project(my_project
LANGUAGES C CXX # C is needed for curl
)
FetchContent_Declare(curl
URL https://curl.se/download/curl-7.83.1.tar.gz
)
FetchContent_Declare(curlcpp
GIT_REPOSITORY https://github.com/JosephP91/curlcpp.git
GIT_TAG "55bc50c244ecb5a14ac21b3b2e2931267a5bb802"
)
FetchContent_MakeAvailable(curl curlcpp)
target_link_libraries(lib_${PROJECT_NAME}
libcurl
curlcpp
)