# find\_package(CURL COMPONENTS ...) doesn't work properly

**URL:** https://discourse.cmake.org/t/find-package-curl-components-doesnt-work-properly/13749
**Category:** Usage
**Created:** [March 14, 2025, 12:32am UTC](https://discourse.cmake.org/t/find-package-curl-components-doesnt-work-properly/13749 "2025-03-14T00:32:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![simoneves](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@simoneves](https://discourse.cmake.org/u/simoneves)
#### Post date: [March 14, 2025, 12:32am UTC](https://discourse.cmake.org/t/find-package-curl-components-doesnt-work-properly/13749/1 "2025-03-14T00:32:06Z")

</div>

I am trying to build libcpr ([GitHub - libcpr/cpr: C++ Requests: Curl for People, a spiritual port of Python Requests.](https://github.com/libcpr/cpr)) 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

```auto
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.
