summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakePresetsGraphReadJSON.cxx5
-rw-r--r--Source/cmJSONHelpers.h6
-rw-r--r--Source/cmJSONState.h1
3 files changed, 11 insertions, 1 deletions
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 1cf9500..108dfa2 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -40,7 +40,7 @@ using cmCMakePresetsGraphInternal::BaseMacroExpander;
using cmCMakePresetsGraphInternal::ExpandMacros;
constexpr int MIN_VERSION = 1;
-constexpr int MAX_VERSION = 9;
+constexpr int MAX_VERSION = 10;
struct CMakeVersion
{
@@ -528,6 +528,9 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename,
return false;
}
+ // Support for $comment added in version 10.
+ this->parseState.allowComments = (v >= 10);
+
RootPresets presets;
if ((result = RootPresetsHelper(presets, &root, &parseState)) != true) {
return result;
diff --git a/Source/cmJSONHelpers.h b/Source/cmJSONHelpers.h
index 24884ed..368a0df 100644
--- a/Source/cmJSONHelpers.h
+++ b/Source/cmJSONHelpers.h
@@ -119,6 +119,12 @@ struct cmJSONHelperBuilder
extraFields = value->getMemberNames();
}
+ if (state->allowComments) {
+ extraFields.erase(
+ std::remove(extraFields.begin(), extraFields.end(), "$comment"),
+ extraFields.end());
+ }
+
for (auto const& m : this->Members) {
std::string name(m.Name.data(), m.Name.size());
state->push_stack(name, value);
diff --git a/Source/cmJSONState.h b/Source/cmJSONState.h
index 9071268..ccf2b71 100644
--- a/Source/cmJSONState.h
+++ b/Source/cmJSONState.h
@@ -65,6 +65,7 @@ public:
std::vector<JsonPair> parseStack;
std::vector<Error> errors;
std::string doc;
+ bool allowComments;
private:
std::string GetJsonContext(Location loc);