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] How to get the root path of a dependency? #16515

Closed PauloCarvalhoRJ closed 1 week ago

PauloCarvalhoRJ commented 1 week ago

Greetings,

I'm currently migrating from Conan 1 and I have recipe code like this:

    self.deps_cpp_info["zlib"].rootpath

From what I learned so far, I now need to use, in generate():

    self.dependencies[self.tested_reference_str].cpp_info.rootpath

However, there is no rootpath attribute in cpp_info object: https://docs.conan.io/2/reference/conanfile/methods/package_info.html#conan-conanfile-model-cppinfo . All the attributes that are directories are relative paths (e.g. include dirs). So, how can I have the same information that rootpath used to provide with the new cpp_info attributes?

thanks,

PC

Have you read the CONTRIBUTING guide?

memsharded commented 1 week ago
self.dependencies["mydep"].package_folder

The package folder is a property of the dependency, not cpp_info now.

Still, when using from a consumer in generate() things like sefl.dependencies["mydep"].cpp_info.includedirs should be absolute paths.

PauloCarvalhoRJ commented 1 week ago

That API makes more sense indeed. True, sefl.dependencies["mydep"].cpp_info.includedirs has an absolute path, but I couldn't know beforehand which level it is with respect to the package's, hence the need for a separate attribute to return the dependency package's path.

Thanks yet again.