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] CppInfo object when using components #16472

Open mikirothman opened 2 weeks ago

mikirothman commented 2 weeks ago

What is your question?

Hi

When defining package layout, the cpp_info object is getting some default values (unless overridden). for example:

def package_info(self):

self.cpp_info.bindirs = ['bin']
self.cpp_info.libdirs = ['lib']
self.cpp_info.includedirs = ['include']

now, let's assume that we have components package, and assume that we have different layout for each component:

def package_info(self):

self.cpp_info.components['x'].bindirs = ['bin/x']
self.cpp_info.components['x'].libdirs = ['lib/x']
self.cpp_info.components['x'].includedirs = ['include/x']
self.cpp_info.components['x'].bindirs = ['bin/y']
self.cpp_info.components['x'].libdirs = ['lib/y']
self.cpp_info.components['x'].includedirs = ['include/y']

we will still get the defaults for the cpp_info.bindirs / cpp_info.libdirs / cpp_info.includedirs, I think when a component is being declared, the default values should be removed and set by the aggregation of the components data.

I can see at least 2 use cases when it's required:

  1. when using deployers, and we want to copy all bins to deployment folder, we would not want to distinguish between components package or single library package.
  2. when linking to the entire package - for example in cmake target_link_directories(MyTarget PRIVATE SomeSdk::SomeSdk)

What do you think?

Have you read the CONTRIBUTING guide?