← All tasks
cpplibcpr/cpr #1247Not a task: not reproduced

Use existing curl cmake target if it already exists

envgap__libcpr__cpr-1247

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
6c605a4c0d139776d92a66ff993216250c9e67b6
Manifest
CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

libcpr/cpr #1247 · read the original issue
### Is your feature request related to a problem?

The only options for managing the curl dependency is either finding it on the system or via `FetchContent`. It would be useful if the project checked if the `libcurl` or `CURL::libcurl` target already existed instead of always managing the dependency itself. A project may have reason to find and use curl outside of its use with CPR or select a specific version of it.

### Possible Solution

Add an initial check [here](https://github.com/libcpr/cpr/blob/a0ff651296a620ed5fabf7d12cf4905fefc7ce86/CMakeLists.txt#L192) for existing curl targets, to avoid handling the dependency at all if one already exists.

```cmake
if(TARGET libcurl OR TARGET CURL::libcurl)
# nothing needs to be done
elseif(CPR_USE_SYSTEM_CURL)
...
```

### Alternatives

If default behaviour needs to remain the same, then this could be an explicit option instead:
```cmake
if(CPR_USE_EXISTING_CURL_TARGET and NOT (TARGET libcurl OR TARGET CURL::libcurl))
    message(FATAL_ERROR "curl target not found...")
elseif(CPR_USE_SYSTEM_CURL)
...
```

### Additional Context

_No response_
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]