docs icon indicating copy to clipboard operation
docs copied to clipboard

[question] How can I get sub graph of a dependency in a recipe?

Open SpaceIm opened this issue 2 years ago • 2 comments

What is your question?

I need to find libs in topological order of a dependency (openssl) and its dependencies, in order to get their libs, lib dirs, include dirs, defines, system libs/frameworks so that I can patch a CMakeLists for check_symbol_exists() (for the well known bug in targets defined by CMakeDeps not working with these functions: https://github.com/conan-io/conan/issues/12012 & https://github.com/conan-io/conan/issues/12180). I don't want the full graph (other unrelated dependencies of this recipe), and I don't want only cpp_info of openssl (I need also its dependencies (there might be zlib depending on an openssl option)).

How can I do that with self.dependencies?

Have you read the CONTRIBUTING guide?

  • [ ] I've read the CONTRIBUTING guide

SpaceIm avatar Sep 30 '23 20:09 SpaceIm

Thanks for your question @SpaceIm

In https://docs.conan.io/2/reference/tools/cpp_info.html?highlight=topological_sort#aggregating-information-in-custom-generators you have the topological_sort iterator of dependencies, returning them in order.

Moving this to docs repo for better docs for this

memsharded avatar Sep 30 '23 21:09 memsharded

Thanks @memsharded , in this example all dependencies of current recipe are aggregated, but I don't understand how to aggregate a sub part of the graph (openssl and its dependencies, openssl being one of the dependencies of current recipe). The problem is that conan objects are not always typed, so I don't always know what I'm manipulating and what is returned. For example self.dependencies doesn't seem to be the same type than self.dependencies[dep].dependencies, and my IDE doesn't give any type information for the later, and conan doc doesn't give much detail.

Here is what I've done (it works but it's ugly): https://github.com/conan-io/conan-center-index/blob/daf4299e60642fc281c01afbb46607bfb8570a48/recipes/dcmtk/all/conanfile.py#L162-L220

SpaceIm avatar Sep 30 '23 22:09 SpaceIm