Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented cache_variables in CMakeToolchain #2611

Merged
merged 3 commits into from Jun 28, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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. This variables, unlike the ``variables`` are single-config. They
czoido marked this conversation as resolved.
Show resolved Hide resolved
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