Skip to content

Commit d2aae83

Browse files
authored
build_folder_vars consts (#3800)
1 parent f2ddad4 commit d2aae83

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

reference/tools/cmake/cmake_layout.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ conf
5555

5656
``cmake_layout`` is affected by these ``[conf]`` variables:
5757

58-
- **tools.cmake.cmake_layout:build_folder_vars** list of settings, options and/or ``self.name`` and ``self.version`` to
58+
- **tools.cmake.cmake_layout:build_folder_vars** list of settings, options, ``self.name`` and ``self.version`` and constants ``const.xxx`` to
5959
customize the ``conanfile.folders.build`` folder. See section :ref:`cmake_layout_multi_name` below.
6060
- **tools.cmake.cmake_layout:build_folder** (*new since Conan 2.2.0*)(*experimental*) uses its value as the base folder of the ``conanfile.folders.build``
6161
for local builds.
@@ -71,7 +71,7 @@ Multi-setting/option cmake_layout
7171

7272
The ``folders.build`` and ``conanfile.folders.generators`` can be customized to take into account the ``settings``
7373
and ``options`` and not only the ``build_type``. Use the ``tools.cmake.cmake_layout:build_folder_vars``
74-
conf to declare a list of settings, options and/or ``self.name`` and ``self.version``:
74+
conf to declare a list of settings, options and/or ``self.name`` and ``self.version`` and user constants:
7575

7676
.. code:: bash
7777
@@ -100,6 +100,13 @@ The values assigned by the ``cmake_layout`` (installing the Release/shared confi
100100

101101

102102
So we can keep separated folders for any number of different configurations that we want to install.
103+
Recipe attributes like name and version and user constants can also be used:
104+
105+
.. code:: bash
106+
107+
$ conan install . -c tools.cmake.cmake_layout:build_folder_vars="['const.myvalue, 'self.name']"
108+
109+
And it will create folders like ``build/myvalue-pkgname``.
103110

104111
The ``CMakePresets.json`` file generated at the :ref:`CMakeToolchain<conan_tools_cmaketoolchain>`
105112
generator, will also take this ``tools.cmake.cmake_layout:build_folder_vars`` config into account to generate different

reference/tools/cmake/cmaketoolchain.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ translated from the current ``settings``:
9595
- By default, preset names will be `conan-xxxx`, but the "conan-" prefix can be
9696
customized with the `CMakeToolchain.presets_prefix = "conan"` attribute.
9797
- Preset names are controlled by the `layout()` `self.folders.build_folder_vars`
98-
definition, which can contain a list of settings, options and/or
99-
``self.name`` and ``self.version`` like
100-
`["settings.compiler", "settings.arch", "options.shared"]`.
98+
definition, which can contain a list of settings, options,
99+
``self.name`` and ``self.version`` and constants ``const.xxx`` like
100+
`["settings.compiler", "settings.arch", "options.shared", "const.myname"]`.
101101
- If CMake is found as a direct `tool_requires` dependency, or if
102102
`tools.cmake:cmake_program` is set, the configure preset will include a
103103
`cmakeExecutable` field. This field represents the path to the CMake executable
@@ -752,7 +752,7 @@ This block injects ``$`` which will be expanded later. It also defines a cache v
752752

753753
- **tools.cmake.cmaketoolchain:toolset_arch**: Will add the ``,host=xxx`` specifier in the ``CMAKE_GENERATOR_TOOLSET`` variable of ``conan_toolchain.cmake`` file.
754754
- **tools.cmake.cmaketoolchain:toolset_cuda**: (Experimental) Will add the ``,cuda=xxx`` specifier in the ``CMAKE_GENERATOR_TOOLSET`` variable of ``conan_toolchain.cmake`` file.
755-
- **tools.cmake.cmake_layout:build_folder_vars**: Settings, Options, and/or ``self.name`` and ``self.version`` that will produce a different build folder and different CMake presets names.
755+
- **tools.cmake.cmake_layout:build_folder_vars**: Settings, Options, ``self.name`` and ``self.version`` and constants ``const.uservalue`` that will produce a different build folder and different CMake presets names.
756756
- **tools.cmake.cmaketoolchain:presets_environment**: Set to ``'disabled'`` to prevent the addition of the environment section to the generated CMake presets.
757757
- **tools.build:cxxflags** list of extra C++ flags that will be appended to ``CMAKE_CXX_FLAGS_INIT``.
758758
- **tools.build:cflags** list of extra of pure C flags that will be appended to ``CMAKE_C_FLAGS_INIT``.

0 commit comments

Comments
 (0)