I am trying to build libcpr (GitHub - libcpr/cpr: C++ Requests: Curl for People, a spiritual port of Python Requests.) against Curl 8.9.1
The libcpr CMakeLists.txt does find_package(CURL COMPONENTS HTTP HTTPS) but reports CURL_FOUND false.
It seems there is some failure in the behavior of FindCURL.cmake in the case where curl-config is not found and it uses pkgconfig instead.
pkg_get_variable(CURL_SUPPORTED_PROTOCOLS_LIST libcurl supported_protocols)
doesn’t return a list of “HTTP”, “HTTPS”, “FILE” etc. but a list containing one item which is itself a string with the space-separate tokens “HTTP HTTPS FILE …”, straight from the libcurl.pc file.
However the rest of FindCURL.cmake expects it to be an actual list, and the find logic fails and concludes that none of the COMPONENTS are present and returns CURL_FOUND = false.
My workaround is to change FindCURL.cmake to do this instead
pkg_get_variable(CURL_SUPPORTED_PROTOCOLS_LIST libcurl supported_protocols)
pkg_get_variable(CURL_SUPPORTED_FEATURES_LIST libcurl supported_features)
list(GET CURL_SUPPORTED_PROTOCOLS_LIST 0 CURL_SUPPORTED_PROTOCOLS_STRING)
list(GET CURL_SUPPORTED_FEATURES_LIST 0 CURL_SUPPORTED_FEATURES_STRING)
string(REPLACE " " ";" CURL_SUPPORTED_PROTOCOLS "${CURL_SUPPORTED_PROTOCOLS_STRING}")
string(REPLACE " " ";" CURL_SUPPORTED_FEATURES "${CURL_SUPPORTED_FEATURES_STRING}")
and then libcpr CMakes perfectly.
This is in CMake 3.25 on Linux.