Skip to content

Commit 7ed8b30

Browse files
memshardedAbrilRBS
andauthored
add CMakeConfigDeps (#3999)
* add CMakeConfigDeps * Update incubating.rst Co-authored-by: Abril Rincón Blanco <[email protected]> * Update incubating.rst Co-authored-by: Abril Rincón Blanco <[email protected]> --------- Co-authored-by: Abril Rincón Blanco <[email protected]>
1 parent 5729570 commit 7ed8b30

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

incubating.rst

+46-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Incubating features
77
This section is dedicated to new features that are under development, looking for user testing and feedback. They are generally behind a flag to enable them to explicitly opt-in on this testing stage. They require the very latest Conan version (sometimes recommended running from the ``develop2`` source branch), and explicitly setting those flags.
88

99

10-
New CMakeDeps generator
11-
-----------------------
10+
New CMakeConfigDeps generator
11+
-----------------------------
1212

1313
This generator is designed as a replacement of the current ``CMakeDeps`` generator, with multiple pending fixes and improvements that couldn't easily be done in the current one without breaking:
1414

@@ -24,11 +24,17 @@ This generator is designed as a replacement of the current ``CMakeDeps`` generat
2424
- Executables from ``requires`` can also be used in non cross-build scenarios. When a ``tool_requires`` to the same depependency exists, then those executables will have priority.
2525
- Creation of a new ``conan_cmakedeps_paths.cmake`` that contains definitions of ``<pkg>_DIR`` paths for direct finding of the dependencies. This file is also planned to be used in ``cmake-conan`` to extend its usage and avoid some current limitations due to the fact that a CMake driven installation cannot inject a toolchain later.
2626

27+
.. note::
28+
29+
This generator is only intended to generate ``config.cmake`` config files, it will not generate ``Find*.cmake`` find modules, and support for it is not planned.
30+
Use the ``CMakeDeps`` generator for that.
31+
32+
2733
The new fields that can be defined in the ``cpp_info`` or ``cpp_info.components``, besides the already defined in :ref:`CppInfo<conan_conanfile_model_cppinfo>` are:
2834

2935
.. code-block:: python
3036
31-
# EXPERIMENTAL FIELDS, used exclusively by new CMakeDeps (-c tools.cmake.cmakedeps:new)
37+
# EXPERIMENTAL FIELDS, used exclusively by new CMakeConfigDeps (-c tools.cmake.cmakedeps:new)
3238
self.cpp_info.type # The type of this artifact "shared-library", "static-library", etc (same as package_type)
3339
self.cpp_info.location # full location (path and filename with extension) of the artifact
3440
self.cpp_info.link_location # Location of the import library for Windows .lib associated to a dll
@@ -40,12 +46,45 @@ These fields will be auto-deduced from the other ``cpp_info`` and ``components``
4046

4147
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.
4248

43-
Known current limitations:
49+
This new generator will also be usable in ``conanfile`` files with:
4450

45-
- At the moment it is limited to ``xxx-config.cmake`` files. It will not generate find modules yet.
46-
- Some paths in ``conan_cmakedeps_paths.cmake`` might be missing yet, only ``CMAKE_PROGRAM_PATH`` is defined at the moment besides the packages ``<pkg>_DIR`` locations.
51+
.. code-block::
52+
:caption: conanfile.txt
53+
54+
[generators]
55+
CMakeConfigDeps
56+
57+
.. code-block:: python
58+
:caption: conanfile.py
59+
60+
class Pkg(ConanFile):
61+
generators = "CMakeConfigDeps"
62+
63+
Or:
64+
65+
.. code-block:: python
66+
:caption: conanfile.py
67+
68+
from conan import ConanFile
69+
from conan.tools.cmake import CMakeConfigDeps
70+
71+
class TestConan(ConanFile):
72+
73+
def generate(self):
74+
deps = CMakeConfigDeps(self)
75+
deps.generate()
76+
77+
78+
The ``-c tools.cmake.cmakedeps:new=will_break_next`` is still necessary for this recipe ``CMakeConfigDeps`` usage, if the config is not enabled, those recipes will fail.
79+
It is also possible to define ``-c tools.cmake.cmakedeps:new=recipe_will_break`` to enable exclusively the ``CMakeConfigDeps`` generators usages, but not the automatic
80+
replacement of existing ``CMakeDeps`` by the ``CMakeConfigDeps``.
81+
82+
Note that the feature is still "incubating", even for the explicit ``CMakeConfigDeps`` generator syntax, this recipe is subject to break or be removed at any time.
83+
84+
For any feedback, please open new tickets in https://github.com/conan-io/conan/issues.
85+
This feedback is very important to stabilize the feature and get it out of incubating, so even if it worked fine and you found no issue, having the positive feedback
86+
reported is very useful.
4787

48-
For any feedback, please open new tickets in https://github.com/conan-io/conan.
4988

5089
Workspaces
5190
----------

0 commit comments

Comments
 (0)