summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-presets.7.rst7
-rw-r--r--Help/manual/presets/schema.json18
-rw-r--r--Help/release/dev/preset-includes-macro-expansion.rst7
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx7
-rw-r--r--Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros-stdout.txt5
-rw-r--r--Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros.json.in10
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake1
7 files changed, 53 insertions, 2 deletions
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index fc0e1f9..5e91ae5 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -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
^^^^^^^^^^^^^^^^
diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json
index d27faa1..f80685c 100644
--- a/Help/manual/presets/schema.json
+++ b/Help/manual/presets/schema.json
@@ -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": [
diff --git a/Help/release/dev/preset-includes-macro-expansion.rst b/Help/release/dev/preset-includes-macro-expansion.rst
new file mode 100644
index 0000000..83aace4
--- /dev/null
+++ b/Help/release/dev/preset-includes-macro-expansion.rst
@@ -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.
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 47a3514..1cf9500 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -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) {
diff --git a/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros-stdout.txt b/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros-stdout.txt
new file mode 100644
index 0000000..d3f1afc
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros-stdout.txt
@@ -0,0 +1,5 @@
+^Not searching for unused variables given on the command line\.
+Available configure presets:
+
+ "Include"
+ "IncludeCommon"$
diff --git a/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros.json.in b/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros.json.in
new file mode 100644
index 0000000..c5693b5
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/IncludeExpansionOtherMacros.json.in
@@ -0,0 +1,10 @@
+{
+ "version": 9,
+ "include": ["${sourceDir}/IncludeCommon.json"],
+ "configurePresets": [
+ {
+ "name": "Include",
+ "inherits": ["IncludeCommon"]
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 88027fb..42a4ed9 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -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)