-
Notifications
You must be signed in to change notification settings - Fork 190
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 and CPMFindPackage have different behaviors #132
Comments
I think is a scoping problem because |
Hey, thanks for the report! The problem is indeed that Basically, If the dependency does depend on variables, I'm not really sure what we can do about this as usually the generated CMake module scripts (used by |
Thanks for the explanation. Those are nice notes for the documentation too, I have a better understanding of the requirements for using Perhaps this can be a suggested workaround in the documentation for cases where the dependency's config.cmake file doesn't export targets.
Scoping aside, I think that's the user's responsibility. I work around this for the current dependency by setting a single variable when
|
Thanks for the feedback, I agree that this should be mentioned in the documentation. Also your user-side workaround makes sense, I'll see that we add this to the docs soon. |
@TheLartians You could export those variables by inspecting the directory property |
I'm having a similar issue with a project "A" that gets Catch2 via CPM but also includes project "B" that gets Catch2 via Fetchcontent. When I configure the project, the FetchContent call in project B doesn't see that CPM has already got Catch2 so tries to get it again and fails with the following error:
The relevant section of the cmake file for project A is:
And project B:
I've tried setting CATCH2_LIBRARIES as per the above example and also tried setting catch2_POPULATED but this just gets set back to false by the call to FetchContent_GetProperties(catch2) |
Hey @apGribble thanks for the comment, that is an interesting use-case. I think the issue could be due CPM.cmake currently bypassing CPMAddPackage(
NAME catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2
VERSION 2.10.2
++ NO_CACHE TRUE
) |
Yeah that removes the error. |
Yeah, each invocation of FetchContent currently comes with a significant (100 - 1000 ms) performance penalty, even if all sources are already cached. The CMake maintainers are aware of this and already working on a fix though. |
Hello,
I'm using CPMFindPackage() to check for a dependency on CMocka and noticing some strange behavior with the
find_package
portion. Do you know what I might be doing wrong here?The library is installed on my system with a CMake config file. I see this output from CPM, but the FOUND/ADDED variables are not set, and the other variables defined by the config file aren't used.
If I remove
CPMFindPackage
and addfind_package
:This time,
CMOCKA_FOUND
will be defined, and the values defined by the config file are used.The text was updated successfully, but these errors were encountered: