conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.25k stars 980 forks source link

[question] Set cmake_find_mode for all deps in CMakeDeps [conan 2] #16546

Closed forry closed 4 months ago

forry commented 4 months ago

What is your question?

Hello, let's say I have a conanfile for building an application with many requirements and I want the CMakeDeps only to generate the config variant. How to do it? Is there some reason to have them both be generated? I think Both of them will have the same info.

I found out that I can do for one of them:

def generate(self):
        deps = CMakeDeps(self)
        deps.set_property("openssl","cmake_find_mode","config")
        deps.generate()

I was hoping that deps.set_property("*","cmake_find_mode","config") will do it.

conan 2.4.1.

Have you read the CONTRIBUTING guide?

AbrilRBS commented 4 months ago

A valid workaround would be to use the self.dependencies accessor, something like:

for dep in self.dependencies.values():
    deps.set_property(dep.ref.name, "cmake_find_mode", "config")

You can also use the filtering functionality of self.dependencies to only have this applied for some dependencies, like self.dependencies.direct etc.

Let me know if that helps :)

forry commented 4 months ago

Thank you very much!