Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_package for CMake #792

Closed
jmafc opened this issue Jul 21, 2022 · 5 comments
Closed

find_package for CMake #792

jmafc opened this issue Jul 21, 2022 · 5 comments

Comments

@jmafc
Copy link

jmafc commented Jul 21, 2022

Is your feature request related to a problem? Please describe.
The suggested approach of using FetchContent to include cpr causes it (and everything else) to be checked and rebuilt (including all of curl and its tests) any time I tweak my CMakeLists.txt (which I've been doing rather frequently because I'm migrating other programs--and only two of which use cpr and those are essentially done).

Describe the solution you'd like
A find_package alternative to the FetchContent suggestion.

Describe alternatives you've considered
I built cpr locally and installed it to /usr/local/lib and added find_package to my CMakeLists.txt. However, cmake complained about not being able to find cprConfig.cmake or cpr-config.cmake. Since the latter file exists in your root directory, I copied it manually to /usr/local/lib/cmake/CPR. However, cmake now complains:

CMake Error at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
  Could NOT find CPR (missing: CPR_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/lib/cmake/CPR/cpr-config.cmake:21 (find_package_handle_standard_args)

So what I'm really asking is that the work that was started when that cpr-config.cmake was created be completed so that find_package can be used.

Additional context
Using cpr 1.9.0 on Debian 11.

@jmafc
Copy link
Author

jmafc commented Jul 21, 2022

Looking a little closer, I see that #645 was a PR that attempted to fix this problem and that created the file cmake/cprConfig.cmake.in (so the older cpr-config.cmake can probably be removed). It also modified the cpr/CMakeLists.txt to create the cprTargets.cmake needed by the .in file. However, I cannot find the cprTargets.cmake file in build directory tree after doing a cmake --build .. So, instead of being a "feature request", this ought to be considered a bug.

@KingKili
Copy link
Member

In order for the CPR config to be installed, you must use the libcurl of your system (CPR_FORCE_USE_SYSTEM_CURL). Then it should all work as requested after a make install.

@jmafc
Copy link
Author

jmafc commented Jul 22, 2022

OK, tested and that does work. However, that fact and the procedure for using Cmake find_package s perhaps should be mentioned in the main README?

@COM8
Copy link
Member

COM8 commented Jul 25, 2022

@jmafc Would you like to create a PR for this?

@jmafc
Copy link
Author

jmafc commented Jul 25, 2022

Not at this time. Sorry. You may close the issue if you want.

@COM8 COM8 closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants