Closed philsuess closed 1 month ago
I am one step closer to what I need. I can indeed access the components
field in cpp_info
like this:
for dep, dep_info in self._conanfile.dependencies.items():
deps_info += f"{dep.ref.name}, {dep.ref.version}, libs: {dep_info.cpp_info.libs}\n"
for k, c in dep_info.cpp_info.components.items():
deps_info += f"\t more libs found via components: {c.libs}\n"
save(self._conanfile, "deps.txt", deps_info)
This way I can get at all libs. Output in deps.txt is then:
coin-clp, 1.17.7, libs: []
more libs found via components: ['ClpSolver', 'Clp']
more libs found via components: ['OsiClp']
coin-osi, 0.108.7, libs: []
more libs found via components: ['Osi']
more libs found via components: ['OsiCommonTests']
coin-utils, 2.11.9, libs: ['CoinUtils']
bzip2, 1.0.8, libs: ['bz2']
zlib, 1.3.1, libs: ['z']
So: it works for me. But it's not really consistent and doesn't feel good to have to search for the info in many places. Thoughts?
That is by design in Conan. Plain self.cpp_info.libs
does not get set if any components are defined.
You can use dep_info.cpp_info.aggregated_components().libs
instead.
Thank you @valgur. I did not know that. Mystery solved and one step smarter. :+1:
Description
It seems that some packages, coin-clp is among them, don't populate
cpp_info.libs
. In the recipe, it sayswhereas in the recipe for coin-utils (where everything is populated fine) it says:
I noticed this because I am writing a generator to produce a dependency info for a
rust.rs
setup and I usecpp_info
to get at libs, libdirs, and includedirs.Am I missing something?
Package and Environment Details
Conan profile
[settings] os=Linux arch=x86_64 compiler=gcc compiler.version=11 compiler.libcxx=libstdc++11 compiler.cppstd=17 build_type=Release
Steps to reproduce
follow steps to create your own generator here: https://docs.conan.io/2/reference/extensions/custom_generators.html#custom-generators-as-python-requires
Then alter the generator conanfile in
mygenerator/conanfile.py
to the following:This is the output in deps.txt:
Note that coin-clp and coin-osi don't populate
cpp_info.libs
.Logs
Click to expand log
``` conan create mygenerator conan install . -pr:b gcc11 -pr:h gcc11 ``` gcc11 holds the profile shown above. The result is a dep.txt file with the content shown above.