diff --git a/reference/tools/cmake/cmakedeps.rst b/reference/tools/cmake/cmakedeps.rst index 959035f2fdce..96b03e4df61e 100644 --- a/reference/tools/cmake/cmakedeps.rst +++ b/reference/tools/cmake/cmakedeps.rst @@ -252,6 +252,12 @@ The following properties affect the CMakeDeps generator: - **cmake_additional_variables_prefixes**: List of prefixes to be used when creating CMake variables in the config files. These variables are created with ``file_name`` as prefix by default, but setting this property will create additional variables with the specified prefixes alongside the default ``file_name`` one. +- **cmake_extra_variables**: Dictionary of extra variables to be added to the generated config file. + The keys of the dictionary are the variable names and the values are the variable values, + which can be a plain string, a number or a dict-like python object which must specify + the ``value`` (string/number) , ``cache`` (boolean), ``type`` (CMake cache type) and optionally, + ``docstring`` (string: defaulted to variable name) and ``force`` (boolean) keys. Note that this has + less preference over those values defined in the ``tools.cmake.cmaketoolchain:extra_variables`` conf. Example: @@ -282,6 +288,14 @@ Example: # Generate both MyFileNameConfig.cmake and FindMyFileName.cmake self.cpp_info.set_property("cmake_find_mode", "both") + # Add extra variables to the generated config file + self.cpp_info.set_property("cmake_extra_variables", { + "FOO": 42, + "CMAKE_GENERATOR_INSTANCE": "${GENERATOR_INSTANCE}/buildTools/", + "CACHE_VAR_DEFAULT_DOC": {"value": "hello world", + "cache": True, "type": "STRING"} + }) + Overwrite properties from the consumer side using CMakeDeps.set_property() ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++