conan-io / conan

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

package_info cpp_info components #16487

Closed wizard-123 closed 2 weeks ago

wizard-123 commented 2 weeks ago

What is your question?

self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs = [f"lib/cmake/vtk-9.3"]
self.cpp_info.components[full_name].builddirs.append("lib")

When I create the conan version of vtk, the settings are as above, where the full_name is custom for me, not a member of components, and I find that the CMAKE_PREFIX_PATH becomes "...../lib" instead of "..../lib/cmake/vtk-9.3"

Have you read the CONTRIBUTING guide?

memsharded commented 2 weeks ago

Hi @wizard-123

Thanks for your question.

When defining components, most of the global values are dropped, they are not additive (we have tried, but it would have been breaking behavior, so we couldn't move it forward), so only the components values are taken into account.

So if all components for example want to define the include directories as "inc", they have to do self.cpp_info.components["compX"].includedirs = ["inc"] for every component, the self.cpp_info.includedirs is discarded and not used.

wizard-123 commented 2 weeks ago

Thank you for your answer, but I am still confused about why the cmake enviroment variable CMAKE_PREFIX_PATH is set to the component‘s .builddirs instead of the root’s .builddirs during the configuring process of the test package.

memsharded commented 2 weeks ago
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs = [f"lib/cmake/vtk-9.3"]  # This doesn't have effect, it is discarded
self.cpp_info.components[full_name].builddirs.append("lib")  # Only this one has effect

Line 2 doesn't have any effect, once components are defined, the only definition that counts is the components one in Line 3. Does this clarify the issue?

wizard-123 commented 2 weeks ago

Thank you very much for resolving my question