Closed bernedom closed 8 months ago
@bernedom Thanks for this great and detailed issue report.
I created a fix for it in #1013.
FetchContent_Declare(
cpr
GIT_REPOSITORY https://github.com/libcpr/cpr.git
GIT_TAG 4018a76d953b60b227ed496caa7375af465dfc6c
OVERRIDE_FIND_PACKAGE)
fixes it in your example.
Once merged, I will backport this fix to 1.10.x
Decided against porting it to 1.10.x since there will be soonish a 1.11.0 release.
Description
When building and installing cpr using curl that is not installed in the system no CMake export sets are created, possibly leading to errors in projects dependent on cpr. When installing projects dependent on cpr the following CMake error might pop up:
CMake Error: install(EXPORT "myProject_Targets" ...) includes target "myProject" which requires target "cpr" that is not in any export set.
Is there a specific reason why the exports are omitted in this case?
For most builds this is not an issue, but it can become an issue if CMakes
FetchContent
together with find_package is used to build a dependency tree. (This is not a very good way to handle dependencies, but it beats checking in binaries to git)Example/How to Reproduce
See the CMakeLists.txt in the following example. https://github.com/bernedom/CPR_Export_Failure_Example
To build it use
Configuration should fail with the following error:
CMake Error: install(EXPORT "unleash_Targets" ...) includes target "unleash" which requires target "cpr" that is not in any export set.
Possible Fix
the fix would be changing ln 81ff in In the file https://github.com/libcpr/cpr/blob/master/cpr/CMakeLists.txt like this:
Where did you get it from?
GitHub (branch e.g. master)
Additional Context/Your Environment
CMake version 3.25 or higher (possibly other versions are also affected)