summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-02-24 09:39:20 -0500
committerBrad King <brad.king@kitware.com>2021-02-24 09:39:20 -0500
commitfcf0c66b5a64040269b45ec0aab84bf62520e3ae (patch)
tree8009399006f9766c75e8fc49148061f44674c1b8
parent289ab61fbeeefd06d29433e3f0c4a700e9793ab4 (diff)
parent431dd59b5e30000c3e3860af69c0dd387634205b (diff)
downloadcmake-fcf0c66b5a64040269b45ec0aab84bf62520e3ae.tar.gz
Merge branch 'backport-3.19-preset-no-comments' into release-3.19
Merge-request: !5853
-rw-r--r--Help/release/3.19.rst9
-rw-r--r--Source/cmCMakePresetsFile.cxx1
-rw-r--r--Tests/RunCMake/CMakePresets/CMakePresets.json.in4
-rw-r--r--Tests/RunCMake/CMakePresets/Comment-result.txt1
-rw-r--r--Tests/RunCMake/CMakePresets/Comment-stderr.txt2
-rw-r--r--Tests/RunCMake/CMakePresets/Comment.json.in11
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CMakePresets/validate_schema.py3
8 files changed, 25 insertions, 7 deletions
diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst
index d8f4f9d79a..1d55f1e57f 100644
--- a/Help/release/3.19.rst
+++ b/Help/release/3.19.rst
@@ -409,7 +409,6 @@ Changes made since CMake 3.19.0 include the following.
:generator:`Visual Studio 14 2015` generator. It has now been fixed to
work with :ref:`Visual Studio Generators` for later VS versions too.
-
3.19.5
------
@@ -425,3 +424,11 @@ Changes made since CMake 3.19.0 include the following.
*Link Binaries With Libraries* build phase broke the ability to switch
between device and simulator builds without reconfiguring. That capability
has now been restored.
+
+3.19.6
+------
+
+* The :manual:`cmake-presets(7)` feature no longer allows comments in
+ ``CMakePresets.json`` or ``CMakeUserPresets.json`` files.
+ This was mistakenly allowed by the implementation in CMake 3.19.0 through
+ CMake 3.19.5, and was not documented.
diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx
index cf5db6ec47..872cb4e638 100644
--- a/Source/cmCMakePresetsFile.cxx
+++ b/Source/cmCMakePresetsFile.cxx
@@ -839,6 +839,7 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile(
Json::Value root;
Json::CharReaderBuilder builder;
+ Json::CharReaderBuilder::strictMode(&builder.settings_);
if (!Json::parseFromStream(builder, fin, &root, nullptr)) {
return ReadFileResult::JSON_PARSE_ERROR;
}
diff --git a/Tests/RunCMake/CMakePresets/CMakePresets.json.in b/Tests/RunCMake/CMakePresets/CMakePresets.json.in
index 54e41403e4..e65c1a920e 100644
--- a/Tests/RunCMake/CMakePresets/CMakePresets.json.in
+++ b/Tests/RunCMake/CMakePresets/CMakePresets.json.in
@@ -1,8 +1,4 @@
-/*
- * Block comment
- */
{
- // Inline comment
"version": 1,
"cmakeMinimumRequired": {
"major": 3,
diff --git a/Tests/RunCMake/CMakePresets/Comment-result.txt b/Tests/RunCMake/CMakePresets/Comment-result.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Comment-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMakePresets/Comment-stderr.txt b/Tests/RunCMake/CMakePresets/Comment-stderr.txt
new file mode 100644
index 0000000000..2f404bc458
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Comment-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: Could not read presets from [^
+]*/Tests/RunCMake/CMakePresets/Comment: JSON parse error$
diff --git a/Tests/RunCMake/CMakePresets/Comment.json.in b/Tests/RunCMake/CMakePresets/Comment.json.in
new file mode 100644
index 0000000000..0f7120c119
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/Comment.json.in
@@ -0,0 +1,11 @@
+// Comment
+{
+ "version": 1,
+ "configurePresets": [
+ {
+ "name": "Comment",
+ "generator": "@RunCMake_GENERATOR@",
+ "binaryDir": "${sourceDir}/build"
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 1ffda3d628..1f399fe108 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -77,6 +77,7 @@ endfunction()
# Test CMakePresets.json errors
set(CMakePresets_SCHEMA_EXPECTED_RESULT 1)
run_cmake_presets(NoCMakePresets)
+run_cmake_presets(Comment)
run_cmake_presets(JSONParseError)
run_cmake_presets(InvalidRoot)
run_cmake_presets(NoVersion)
diff --git a/Tests/RunCMake/CMakePresets/validate_schema.py b/Tests/RunCMake/CMakePresets/validate_schema.py
index c9f84ee176..b2a67fc4b9 100644
--- a/Tests/RunCMake/CMakePresets/validate_schema.py
+++ b/Tests/RunCMake/CMakePresets/validate_schema.py
@@ -1,4 +1,3 @@
-import jsmin
import json
import jsonschema
import os.path
@@ -6,7 +5,7 @@ import sys
with open(sys.argv[1], "rb") as f:
- contents = json.loads(jsmin.jsmin(f.read().decode("utf-8-sig")))
+ contents = json.loads(f.read().decode("utf-8-sig"))
schema_file = os.path.join(
os.path.dirname(__file__),