conan-io / conan

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

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

Closed forry closed 5 days ago

forry commented 5 days 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?

RubenRBS commented 5 days 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 5 days ago

Thank you very much!