New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document CppInfo components and new attributes #1363
Conversation
I miss three ideas to be transmitted in the components section:
- When you are creating a Conan package it is recommended to package only 1 library file (lib, a, so, dll...), but sometimes, especially with third-party projects like Boost, Poco or even OpenSSL, they contain several libraries inside.
- Then it is sometimes necessary to model relations between the libraries of the same Conan package. Typically a library will be a component so if a library depends on another in the same package, you can declare the dependence relationship. The consumer will receive the correct linking order.
- It will allow (NOT IMPLEMENTED YET) to the generators to be more advance in the future. Some examples:
- The CMake
find_package
scripts could allow working with COMPONENTS. - The
name
field declared could determine the name of thexxx-config.cmake
file or the name of thexxx.pc
file for pkg-config and so on.
- The CMake
granularity when linking with packages with more than one library packaged. | ||
- Generate files with appropriate names for CMake config and package config files like: *xxx-config.cmake* or *xxx.pc* | ||
|
||
The structure of the ``Component`` object is the same as the one used by the ``cpp_info`` object and has **the same default directories**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 important notes are needed here:
- That no global definition is possible if you are using components
- That the feature so far is not fully implemented, and at the moment is is only the definition in the conanfile, but is transparent and has no effect on consumers at all, and that is ongoing work.
|
||
The paths of the directories in the directory variables indicated above are relative to the | ||
:ref:`self.package_folder<folders_attributes_reference>` directory. | ||
|
||
.. _cpp_info_components_attributes_reference: | ||
|
||
Components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I would prefer the reference the other way round:
- The attribute is only a placeholder, with a link
- The
package_info()
method is the section of the docs that contains all the detailed information about cpp_info and components.
Not to be changed now, but to have the idea in mind for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will take this into account for next refactors of the documentation
reference/conanfile/attributes.rst
Outdated
|
||
- Generate different targets with appropriate names in CMake to iterate better with ``find_package()`` functionality. This will allow more | ||
granularity when linking with packages with more than one library packaged. | ||
- Generate files with appropriate names for CMake config and package config files like: *xxx-config.cmake* or *xxx.pc* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is something we should mention. Probably all components should go in the same file (is it not possible for any generator?). If the components generate their own file, we can have collisions and Conan won't be able to handle them.
And, as this is totally speculative, I would vote to remove this example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. This was here when the feature was introduced together with the cpp_info.name
attribute. But I think it is better to remove this from the reference right now and explain it better in a dedicated section in the future. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please remove that.
reference/conanfile/attributes.rst
Outdated
@@ -970,6 +1016,10 @@ root folder of the package: | |||
# Get the sharedlinkflags property from OpenSSL package | |||
self.deps_cpp_info["openssl"].sharedlinkflags | |||
|
|||
.. seealso:: | |||
|
|||
Read more about :ref:`cpp_info_components_attributes_reference` in ``self.cpp_info``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is linking to this same section seealso
section, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right
These docs dont explain at all how to use these paths in the consuming recipes, they are very arbitraty. The documentation states:
And it does not link to anything anywhere how to propagate these in cmake or any generator. Can we get some real example somewhere please? comment really to the work itself: |
Docs for conan-io/conan#6653
Issue conan-io/conan#5090