Skip to content

[feature] package_info / CMakeDeps: ability to propagate transitive requirements on cmake built-ins #18222

Open
@jcar87

Description

@jcar87

What is your suggestion?

While for libraries CMake would expect them to provide -config.cmake files (or CPS in the future), CMake does have some nice built ins that provide abstractions for things that are belong in the real of toolchains/system libraries, rather than a pure library package. Some examples are "Threads", "OpenMP", and for some complex cases, Python, CUDAToolkit )

It would be useful if recipes that use these and need to propagate requirements, could cause the generated files to :

  • have a call to find_dependency(xxx) , e.g find_dependency(Threads)
  • be able to tell a Conan-generated Cmake target, to depend on a CMake-find-module-provided target

for example:

def package_info(self):
    self.cpp_info.set_property("cmake_additional_dependencies", ["Threads", "OpenMP"])
    self.cpp_info.components["foobar"].set_property("cmake_target_name", "foobar::libfoo")
    self.cpp_info.components["foobar"].set_property("cmake_additional_interface_link_libraries", ["OpenMP::OpenMP"])

This can help mitigate workarounds like this one for llama, or having to partially replicate existing well-maintained CMake logic, in less-ideally maintained recipe hacks

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions