Skip to content

Commit 4a04668

Browse files
authored
Add cpp_info.sources to CMakeConfigDeps docs (#4128)
* Add cpp_info.sources to CMakeConfigDeps docs * add explanation with small example
1 parent 5d1e77f commit 4a04668

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

incubating.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,20 @@ The new fields that can be defined in the ``cpp_info`` or ``cpp_info.components`
4646
self.cpp_info.languages # same as "languages" attribute, it can be "C", "C++"
4747
self.cpp_info.exe # Definition of an executable artifact
4848
self.cpp_info.package_framework # Definition of an Apple Framework (new since Conan 2.14)
49+
self.cpp_info.sources # List of paths to source files in the package (for packages that provide source code to consumers)
4950
5051
5152
These fields will be auto-deduced from the other ``cpp_info`` and ``components`` definitions, like the ``libs`` or ``libdirs`` fields, but the automatic deduction might have limitations. Defining them explicitly will inhibit the auto deduction and use the value as provided by the recipe.
5253

54+
Declare sources for targets with:
55+
56+
.. code-block:: python
57+
58+
self.cpp_info.sources = ["src/mylib.cpp", "src/other.cpp"]
59+
60+
This allows packages to provide source code as a dependency to consumers. The paths should be relative to the package folder.
61+
The source files will be added as `INTERFACE_SOURCES` property to the CMake library (or component) target and consumers that
62+
link with this target will compile the sources when building their own targets.
5363

5464
This feature is enabled with the ``-c tools.cmake.cmakedeps:new=will_break_next`` configuration. The value ``will_break_next`` will change in next releases to emphasize the fact that this feature is not suitable for usage beyond testing. Just by enabling this conf and forcing the build of packages that use ``CMakeDeps`` will trigger the usage of the new generator.
5565

0 commit comments

Comments
 (0)