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
[question] Is there a way to reference specific targets with the CMake find_package_multi generator? #7116
Comments
This will be the "components" feature. It is on its way, we already added recipe support in past release, and this release will release support for cmake_find_package generators: #7108 Once this is out, the first step would be to contribute the components model to the I am considering that #7108 will close this issue (at least on the Conan CLI side, pending the gtest recipe update) |
For info: it is possible to address specific targets today, but they have undocumented names like CONAN_LIB::gtest and CONAN_LIB::gmock. If you need a solution today, you can use them, otherwise I would recommend for the components feature. |
There's an issue that a component cannot be named the same as a package. So you can't create |
Not necessary to change the name of the package. The |
Yep, I kept that line and it still complains. It seems to check the package name directly.
Here is my new version of
I can open a separate issue if this is unexpected behavior. |
Sorry, this is not closed by #7108, because that only applies to |
@akosik-anyvision with #7259 merged, you will be able to use the components feature with the In order to achieve the behavior you describe above, you will need to declare a "global" (or any other name) component with a different name that the package name. for example, something like this should work:
The reason for this is that apart from components, we also provide a "global" target by default that depends on all the other component targets ( With the approach above, you "override" the global target providing your own one. |
components are available to both generators 🎉 |
Hi,
I'm working on a project with optional conan support. I want fellow devs to be able decide whether or not to use conan, but still have all the cmake logic the same.
I've hit a problem with GTest because the conan find_package_multi generator only creates a GTest::GTest target, but GTest's own config doesn't usually export this target; it exports GTest::gtest, GTest::gmock, etc...
This forces me to use some conditional logic in the cmake file to try linking with both GTest::GTest and GTest::gtest, depending on the package manager.
Is there a way to reference specific library targets like GTest::gtest from conan?
I know you can do it with other cmake generators, but I see no mention of it for the find_package_multi generator.
The text was updated successfully, but these errors were encountered: