Skip to content

Commit ae9f5b0

Browse files
authored
Docs for cmake_extra_variables property (#4257)
* Docs for cmake_extra_variables property * Code example
1 parent eccdf51 commit ae9f5b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

reference/tools/cmake/cmakedeps.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ The following properties affect the CMakeDeps generator:
252252
- **cmake_additional_variables_prefixes**: List of prefixes to be used when creating CMake variables in the config
253253
files. These variables are created with ``file_name`` as prefix by default, but setting this property will create
254254
additional variables with the specified prefixes alongside the default ``file_name`` one.
255+
- **cmake_extra_variables**: Dictionary of extra variables to be added to the generated config file.
256+
The keys of the dictionary are the variable names and the values are the variable values,
257+
which can be a plain string, a number or a dict-like python object which must specify
258+
the ``value`` (string/number) , ``cache`` (boolean), ``type`` (CMake cache type) and optionally,
259+
``docstring`` (string: defaulted to variable name) and ``force`` (boolean) keys. Note that this has
260+
less preference over those values defined in the ``tools.cmake.cmaketoolchain:extra_variables`` conf.
255261

256262
Example:
257263

@@ -282,6 +288,14 @@ Example:
282288
# Generate both MyFileNameConfig.cmake and FindMyFileName.cmake
283289
self.cpp_info.set_property("cmake_find_mode", "both")
284290
291+
# Add extra variables to the generated config file
292+
self.cpp_info.set_property("cmake_extra_variables", {
293+
"FOO": 42,
294+
"CMAKE_GENERATOR_INSTANCE": "${GENERATOR_INSTANCE}/buildTools/",
295+
"CACHE_VAR_DEFAULT_DOC": {"value": "hello world",
296+
"cache": True, "type": "STRING"}
297+
})
298+
285299
286300
Overwrite properties from the consumer side using CMakeDeps.set_property()
287301
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)