Skip to content

Commit

Permalink
build_folder_vars consts (#3800)
Browse files Browse the repository at this point in the history
  • Loading branch information
memsharded authored Jul 31, 2024
1 parent f2ddad4 commit d2aae83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions reference/tools/cmake/cmake_layout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ conf

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

- **tools.cmake.cmake_layout:build_folder_vars** list of settings, options and/or ``self.name`` and ``self.version`` to
- **tools.cmake.cmake_layout:build_folder_vars** list of settings, options, ``self.name`` and ``self.version`` and constants ``const.xxx`` to
customize the ``conanfile.folders.build`` folder. See section :ref:`cmake_layout_multi_name` below.
- **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``
for local builds.
Expand All @@ -71,7 +71,7 @@ Multi-setting/option cmake_layout

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

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


So we can keep separated folders for any number of different configurations that we want to install.
Recipe attributes like name and version and user constants can also be used:

.. code:: bash
$ conan install . -c tools.cmake.cmake_layout:build_folder_vars="['const.myvalue, 'self.name']"
And it will create folders like ``build/myvalue-pkgname``.

The ``CMakePresets.json`` file generated at the :ref:`CMakeToolchain<conan_tools_cmaketoolchain>`
generator, will also take this ``tools.cmake.cmake_layout:build_folder_vars`` config into account to generate different
Expand Down
8 changes: 4 additions & 4 deletions reference/tools/cmake/cmaketoolchain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ translated from the current ``settings``:
- By default, preset names will be `conan-xxxx`, but the "conan-" prefix can be
customized with the `CMakeToolchain.presets_prefix = "conan"` attribute.
- Preset names are controlled by the `layout()` `self.folders.build_folder_vars`
definition, which can contain a list of settings, options and/or
``self.name`` and ``self.version`` like
`["settings.compiler", "settings.arch", "options.shared"]`.
definition, which can contain a list of settings, options,
``self.name`` and ``self.version`` and constants ``const.xxx`` like
`["settings.compiler", "settings.arch", "options.shared", "const.myname"]`.
- If CMake is found as a direct `tool_requires` dependency, or if
`tools.cmake:cmake_program` is set, the configure preset will include a
`cmakeExecutable` field. This field represents the path to the CMake executable
Expand Down Expand Up @@ -752,7 +752,7 @@ This block injects ``$`` which will be expanded later. It also defines a cache v

- **tools.cmake.cmaketoolchain:toolset_arch**: Will add the ``,host=xxx`` specifier in the ``CMAKE_GENERATOR_TOOLSET`` variable of ``conan_toolchain.cmake`` file.
- **tools.cmake.cmaketoolchain:toolset_cuda**: (Experimental) Will add the ``,cuda=xxx`` specifier in the ``CMAKE_GENERATOR_TOOLSET`` variable of ``conan_toolchain.cmake`` file.
- **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.
- **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.
- **tools.cmake.cmaketoolchain:presets_environment**: Set to ``'disabled'`` to prevent the addition of the environment section to the generated CMake presets.
- **tools.build:cxxflags** list of extra C++ flags that will be appended to ``CMAKE_CXX_FLAGS_INIT``.
- **tools.build:cflags** list of extra of pure C flags that will be appended to ``CMAKE_C_FLAGS_INIT``.
Expand Down

0 comments on commit d2aae83

Please sign in to comment.