diff options
author | Brad King <brad.king@kitware.com> | 2021-02-24 14:41:34 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-02-24 14:42:00 (GMT) |
commit | 75d7329adbe5dc2099d2291135c56ebec7b39828 (patch) | |
tree | 35c877a753d77b49e5828fc82d7a1c4bab15e29d | |
parent | cf21ea2ce6b174a69316a39e83616c056fc530e2 (diff) | |
parent | 06e16ea008bf6efbe68028279539cfc6d1ff7a93 (diff) | |
download | CMake-75d7329adbe5dc2099d2291135c56ebec7b39828.zip CMake-75d7329adbe5dc2099d2291135c56ebec7b39828.tar.gz CMake-75d7329adbe5dc2099d2291135c56ebec7b39828.tar.bz2 |
Merge topic 'preset-no-comments' into release-3.20
06e16ea008 Merge branch 'backport-3.19-preset-no-comments' into preset-no-comments
afaa69f5b3 Tests: Remove comments from CMakePresetsTest/Good.json.in
4a92277f45 Revert "Help: Document JSON comment support in cmake-presets(7)"
431dd59b5e CMakePresets.json: Remove undocumented support for comments
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5853
-rw-r--r-- | Help/manual/cmake-presets.7.rst | 5 | ||||
-rw-r--r-- | Help/release/3.19.rst | 9 | ||||
-rw-r--r-- | Source/cmCMakePresetsFile.cxx | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/CMakePresets.json.in | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/Comment-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/Comment-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/Comment.json.in | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresets/validate_schema.py | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMakePresetsTest/Good.json.in | 9 |
10 files changed, 26 insertions, 20 deletions
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 55a9947..467818d 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -29,10 +29,7 @@ is using Git, ``CMakePresets.json`` may be tracked, and Format ====== -The files are JSON documents. C-style comments are allowed using -line-wise ``//`` syntax or block ``/*...*/`` syntax. - -Each document has an object as the root: +The files are a JSON document with an object as the root: .. literalinclude:: presets/example.json :language: json diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst index d8f4f9d..1d55f1e 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 29d5325..c8d69b8 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -1519,6 +1519,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 54e4140..e65c1a9 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 0000000..d00491f --- /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 0000000..2f404bc --- /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 0000000..0f7120c --- /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 25a7f2f..1864ecd 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -63,6 +63,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 c9f84ee..b2a67fc 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__), diff --git a/Tests/RunCMake/CMakePresetsTest/Good.json.in b/Tests/RunCMake/CMakePresetsTest/Good.json.in index 791d41f..57be5a5 100644 --- a/Tests/RunCMake/CMakePresetsTest/Good.json.in +++ b/Tests/RunCMake/CMakePresetsTest/Good.json.in @@ -49,8 +49,6 @@ "outputLogFile": "", "labelSummary": true, "subprojectSummary": true - // "maxPassedTestOutputSize": 0 - // "maxTestNameWidth": 0 }, "filter": { "include": { @@ -58,11 +56,6 @@ "label": "", "useUnion": false, "index": "" - // "index": { - // "start": 0, - // "end": 0, - // "stride": 0 - // } }, "exclude": { "name": "", @@ -79,7 +72,6 @@ "enableFailover": false, "jobs": 0, "resourceSpecFile": "", - // "testLoad": 0, "showOnly": "human", "repeat": { "mode": "until-pass", @@ -87,7 +79,6 @@ }, "interactiveDebugging": false, "scheduleRandom": false, - // "timeout": 0, "noTestsAction": "default" } }, |