mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
presets: Expand more macros in the include directive
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
This commit is contained in:
@@ -78,6 +78,9 @@ The root object recognizes the following fields:
|
||||
``8``
|
||||
.. versionadded:: 3.28
|
||||
|
||||
``9``
|
||||
.. versionadded:: 3.30
|
||||
|
||||
``cmakeMinimumRequired``
|
||||
An optional object representing the minimum version of CMake needed to
|
||||
build this project. This object consists of the following fields:
|
||||
@@ -146,7 +149,9 @@ guaranteed to be provided by the project. ``CMakeUserPresets.json`` may
|
||||
include files from anywhere.
|
||||
|
||||
Starting from version ``7``, the ``include`` field supports
|
||||
`macro expansion`_, but only ``$penv{}`` macro expansion.
|
||||
`macro expansion`_, but only ``$penv{}`` macro expansion. Starting from version
|
||||
``9``, other macro expansions are also available, except for preset specific
|
||||
ones (e.g. ``presetName``), and ``$env{}``.
|
||||
|
||||
Configure Preset
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
@@ -124,6 +124,24 @@
|
||||
"include": { "$ref": "#/definitions/include" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"$schema": { "$ref": "#/definitions/$schema" },
|
||||
"version": {
|
||||
"const": 9,
|
||||
"description": "A required integer representing the version of the JSON schema."
|
||||
},
|
||||
"cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" },
|
||||
"vendor": { "$ref": "#/definitions/vendor" },
|
||||
"configurePresets": { "$ref": "#/definitions/configurePresetsV7" },
|
||||
"buildPresets": { "$ref": "#/definitions/buildPresetsV4" },
|
||||
"testPresets": { "$ref": "#/definitions/testPresetsV6" },
|
||||
"packagePresets": { "$ref": "#/definitions/packagePresetsV6" },
|
||||
"workflowPresets": { "$ref": "#/definitions/workflowPresetsV6" },
|
||||
"include": { "$ref": "#/definitions/include" }
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
|
||||
7
Help/release/dev/preset-includes-macro-expansion.rst
Normal file
7
Help/release/dev/preset-includes-macro-expansion.rst
Normal file
@@ -0,0 +1,7 @@
|
||||
preset-includes-macro-expansion
|
||||
-------------------------------
|
||||
|
||||
* :manual:`cmake-presets(7)` files now support schema version ``9``:
|
||||
|
||||
* ``include`` fields now expand all macros except ``$env{}`` and
|
||||
preset-specific macros.
|
||||
@@ -36,10 +36,11 @@ using JSONHelperBuilder = cmJSONHelperBuilder;
|
||||
using ExpandMacroResult = cmCMakePresetsGraphInternal::ExpandMacroResult;
|
||||
using MacroExpander = cmCMakePresetsGraphInternal::MacroExpander;
|
||||
using MacroExpanderVector = cmCMakePresetsGraphInternal::MacroExpanderVector;
|
||||
using cmCMakePresetsGraphInternal::BaseMacroExpander;
|
||||
using cmCMakePresetsGraphInternal::ExpandMacros;
|
||||
|
||||
constexpr int MIN_VERSION = 1;
|
||||
constexpr int MAX_VERSION = 8;
|
||||
constexpr int MAX_VERSION = 9;
|
||||
|
||||
struct CMakeVersion
|
||||
{
|
||||
@@ -732,6 +733,10 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
|
||||
|
||||
MacroExpanderVector macroExpanders{};
|
||||
|
||||
if (v >= 9) {
|
||||
macroExpanders.push_back(
|
||||
cm::make_unique<BaseMacroExpander>(*this, filename));
|
||||
}
|
||||
macroExpanders.push_back(cm::make_unique<EnvironmentMacroExpander>());
|
||||
|
||||
for (Json::ArrayIndex i = 0; i < presets.Include.size(); ++i) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
^Not searching for unused variables given on the command line\.
|
||||
Available configure presets:
|
||||
|
||||
"Include"
|
||||
"IncludeCommon"$
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": 9,
|
||||
"include": ["${sourceDir}/IncludeCommon.json"],
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "Include",
|
||||
"inherits": ["IncludeCommon"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -407,6 +407,7 @@ set(CMakePresets_EXTRA_FILES
|
||||
set(ENV{TEST_ENV_INCLUDE_DIR} ${RunCMake_BINARY_DIR}/IncludeExpansion)
|
||||
run_cmake_presets(IncludeExpansion --list-presets)
|
||||
unset(ENV{TEST_ENV_INCLUDE_DIR})
|
||||
run_cmake_presets(IncludeExpansionOtherMacros --list-presets)
|
||||
unset(CMakePresets_EXTRA_FILES)
|
||||
run_cmake_presets(IncludeNotFound)
|
||||
run_cmake_presets(IncludeCycle)
|
||||
|
||||
Reference in New Issue
Block a user