summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-10-12 18:03:40 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-10-12 18:04:41 (GMT)
commit9e9447a4278a6d466e08898d205ca9552e31f0b0 (patch)
tree52e782f4ad56f38894550181d1aea6d97891c745
parentdb230150907bb60b966717778d9a653fdddf3a19 (diff)
parent94c955e508daa0ed84290cc1d3e946a74fde0e40 (diff)
downloadCMake-9e9447a4278a6d466e08898d205ca9552e31f0b0.zip
CMake-9e9447a4278a6d466e08898d205ca9552e31f0b0.tar.gz
CMake-9e9447a4278a6d466e08898d205ca9552e31f0b0.tar.bz2
Merge topic 'cmake-presets-documentation-fix'
94c955e508 Tests: Test the CMakePresets.json example in the documentation d6af1e83bc Help: Fix documentation of CMakePresets.json's cacheVariables Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5353
-rw-r--r--Help/manual/cmake.1.rst28
-rw-r--r--Help/manual/presets/example.json23
-rw-r--r--Tests/RunCMake/CMakePresets/DocumentationExample.cmake3
-rw-r--r--Tests/RunCMake/CMakePresets/RunCMakeTest.cmake9
4 files changed, 37 insertions, 26 deletions
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 0f00f53..b345db0 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -174,32 +174,8 @@ source and build trees and generate a buildsystem:
The files are a JSON document with an object as the root:
- .. code-block:: json
-
- {
- "version": 1,
- "cmakeMinimumRequired": {
- "major": 3,
- "minor": 19,
- "patch": 0
- },
- "configurePresets": [
- {
- "name": "default",
- "displayName": "Default Config",
- "description": "Default build using Ninja generator",
- "generator": "Ninja",
- "binaryDir": "${sourceDir}/build/default",
- "cacheVariables": [
- {
- "name": "MY_CACHE_VARIABLE",
- "type": "BOOL",
- "value": "OFF"
- }
- ]
- }
- ]
- }
+ .. literalinclude:: presets/example.json
+ :language: json
The root object recognizes the following fields:
diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json
new file mode 100644
index 0000000..a299a06
--- /dev/null
+++ b/Help/manual/presets/example.json
@@ -0,0 +1,23 @@
+{
+ "version": 1,
+ "cmakeMinimumRequired": {
+ "major": 3,
+ "minor": 19,
+ "patch": 0
+ },
+ "configurePresets": [
+ {
+ "name": "default",
+ "displayName": "Default Config",
+ "description": "Default build using Ninja generator",
+ "generator": "Ninja",
+ "binaryDir": "${sourceDir}/build/default",
+ "cacheVariables": {
+ "MY_CACHE_VARIABLE": {
+ "type": "BOOL",
+ "value": "OFF"
+ }
+ }
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CMakePresets/DocumentationExample.cmake b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake
new file mode 100644
index 0000000..1f2fc00
--- /dev/null
+++ b/Tests/RunCMake/CMakePresets/DocumentationExample.cmake
@@ -0,0 +1,3 @@
+include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake)
+
+test_variable(MY_CACHE_VARIABLE "BOOL" "OFF")
diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
index 4b430b3..18ea093 100644
--- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake
@@ -1,3 +1,5 @@
+cmake_minimum_required(VERSION 3.19) # CMP0053
+
include(RunCMake)
# Fix Visual Studio generator name
@@ -214,3 +216,10 @@ unset(CMakePresets_WARN_UNUSED_CLI)
set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in")
run_cmake_presets(NoDebug)
run_cmake_presets(Debug)
+
+# Test the example from the documentation
+file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example)
+string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}")
+file(WRITE "${RunCMake_BINARY_DIR}/example.json.in" "${_example}")
+set(CMakePresets_FILE "${RunCMake_BINARY_DIR}/example.json.in")
+run_cmake_presets(DocumentationExample --preset=default)