Skip to content

Commit

Permalink
Documented cache_variables in CMakeToolchain (#2611)
Browse files Browse the repository at this point in the history
* Documented cache_variables in CMakeToolchain

* Update reference/conanfile/tools/cmake/cmaketoolchain.rst

Co-authored-by: James <james@conan.io>

* Update reference/conanfile/tools/cmake/cmaketoolchain.rst

Co-authored-by: Francisco Ramírez <franchuti688@gmail.com>

Co-authored-by: James <james@conan.io>
Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
Co-authored-by: Francisco Ramírez <franchuti688@gmail.com>
  • Loading branch information
4 people committed Jun 28, 2022
1 parent caebc52 commit c3293a6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions reference/conanfile/tools/cmake/cmaketoolchain.rst
Expand Up @@ -150,6 +150,24 @@ The booleans assigned to a variable will be translated to ``ON`` and ``OFF`` sym
Will generate the sentences: ``set(FOO ON ...)`` and ``set(VAR OFF ...)``.


cache_variables
+++++++++++++++

This attribute allows defining CMake cache-variables. These variables, unlike the ``variables``, are single-config. They
will be stored in the ``CMakePresets.json`` file (at the `cacheVariables` in the `configurePreset`) and will be
applied with ``-D`` arguments when calling ``cmake.configure`` using the :ref:`CMake() build helper<conan-cmake-build-helper>`.


.. code:: python
def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["foo"] = True
tc.cache_variables["foo2"] = False
tc.cache_variables["var"] = "23"
The booleans assigned to a cache_variable will be translated to ``ON`` and ``OFF`` symbols in CMake.


Generators
++++++++++
Expand Down

0 comments on commit c3293a6

Please sign in to comment.