Commit 0307f7c9 authored by Ben McMorran's avatar Ben McMorran Committed by Kyle Edwards
Browse files

Help: Add JSON schema for CMakePresets.json

parent 81c88bb2
......@@ -69,6 +69,9 @@ While reading, parsing, and evaluating the contents of ``CMakePresets.json`` is
straightforward, it is not trivial. In addition to the documentation, IDE
vendors may also wish to refer to the CMake source code and test cases for a
better understanding of how to implement the format.
:download:`This file </manual/presets/schema.json>` provides a machine-readable
JSON schema for the ``CMakePresets.json`` format that IDE vendors may find
useful for validation and providing editing assistance.
Configuring
===========
......
......@@ -353,3 +353,9 @@ Format
``<macro-name>`` with a very short (preferably <= 4 characters) vendor
identifier prefix, followed by a ``.``, followed by the macro name. For
example, the Example IDE could have ``$vendor{xide.ideInstallDir}``.
Schema
======
:download:`This file </manual/presets/schema.json>` provides a machine-readable
JSON schema for the ``CMakePresets.json`` format.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"description": "The presets specify the generator and the build directory, and optionally a list of variables and other arguments to pass to CMake.",
"properties": {
"version": {
"type": "integer",
"description": "A required integer representing the version of the JSON schema. Currently, the only supported version is 1.",
"minimum": 1,
"maximum": 1
},
"cmakeMinimumRequired": {
"type": "object",
"description": "An optional object representing the minimum version of CMake needed to build this project.",
"properties": {
"major": {
"type": "integer",
"description": "An optional integer representing the major version."
},
"minor": {
"type": "integer",
"description": "An optional integer representing the minor version."
},
"patch": {
"type": "integer",
"description": "An optional integer representing the patch version."
}
},
"additionalProperties": false
},
"vendor": {
"type": "object",
"description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.",
"properties": {}
},
"configurePresets": {
"type": "array",
"description": "An optional array of configure preset objects.",
"items": {
"type": "object",
"description": "A configure preset object.",
"properties": {
"name": {
"type": "string",
"description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.",
"minLength": 1
},
"hidden": {
"type": "boolean",
"description": "An optional boolean specifying whether or not a preset should be hidden. If a preset is hidden, it cannot be used in the --preset= argument, will not show up in the CMake GUI, and does not have to have a valid generator or binaryDir, even from inheritance. hidden presets are intended to be used as a base for other presets to inherit via the inherits field."
},
"inherits": {
"anyOf": [
{
"type": "string",
"description": "An optional string representing the name of the preset to inherit from.",
"minLength": 1
},
{
"type": "array",
"description": "An optional array of strings representing the names of presets to inherit from. The preset will inherit all of the fields from the inherits presets by default (except name, hidden, inherits, description, and longDescription), but can override them as desired. If multiple inherits presets provide conflicting values for the same field, the earlier preset in the inherits list will be preferred. Presets in CMakePresets.json may not inherit from presets in CMakeUserPresets.json.",
"items": {
"type": "string",
"description": "An optional string representing the name of the preset to inherit from.",
"minLength": 1
}
}
]
},
"vendor": {
"type": "object",
"description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, it should follow the same conventions as the root-level vendor field. If vendors use their own per-preset vendor field, they should implement inheritance in a sensible manner when appropriate.",
"properties": {}
},
"displayName": {
"type": "string",
"description": "An optional string with a human-friendly name of the preset."
},
"description": {
"type": "string",
"description": "An optional string with a human-friendly description of the preset."
},
"generator": {
"type": "string",
"description": "An optional string representing the generator to use for the preset. If generator is not specified, it must be inherited from the inherits preset (unless this preset is hidden). Note that for Visual Studio generators, unlike in the command line -G argument, you cannot include the platform name in the generator name. Use the architecture field instead."
},
"architecture": {
"type": "string",
"description": "An optional string representing the platform name to use for Visual Studio generators."
},
"toolset": {
"type": "string",
"description": "An optional string representing the toolset name to use for Visual Studio generators."
},
"cmakeGeneratorConfig": {
"type": "string",
"description": "An optional string telling CMake how to handle the architecture and toolset fields. Valid values are: \"default\": Set the platform and toolset using the architecture and toolset fields respectively. On non-Visual Studio generators, this will result in an error if architecture or toolset are set. \"ignore\": Do not set the platform or toolset at all, even on Visual Studio generators. This is useful if, for example, a preset uses the Ninja generator, and an IDE knows how to set up the Visual C++ environment from the architecture and toolset fields. In that case, CMake will ignore architecture and toolset, but the IDE can use them to set up the environment before invoking CMake.",
"enum": [
"default",
"ignore"
]
},
"binaryDir": {
"type": "string",
"description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, it must be inherited from the inherits preset (unless this preset is hidden)."
},
"cmakeExecutable": {
"type": "string",
"description": "An optional string representing the path to the CMake executable to use for this preset. This is reserved for use by IDEs, and is not used by CMake itself. IDEs that use this field should expand any macros in it."
},
"cacheVariables": {
"type": "object",
"description": "An optional map of cache variables. The key is the variable name (which must not be an empty string). Cache variables are inherited through the inherits field, and the preset's variables will be the union of its own cacheVariables and the cacheVariables from all its parents. If multiple presets in this union define the same variable, the standard rules of inherits are applied.",
"properties": {},
"additionalProperties": {
"anyOf": [
{
"type": "null",
"description": "Setting a variable to null causes it to not be set, even if a value was inherited from another preset."
},
{
"type": "string",
"description": "A string representing the value of the variable (which supports macro expansion)."
},
{
"type": "object",
"description": "An object representing the type and value of the variable.",
"properties": {
"type": {
"type": "string",
"description": "An optional string representing the type of the variable. It should be BOOL, FILEPATH, PATH, STRING, or INTERNAL."
},
"value": {
"type": "string",
"description": "A required string representing the value of the variable. This field supports macro expansion."
}
},
"required": [
"value"
],
"additionalProperties": false
}
]
},
"propertyNames": {
"pattern": "^.+$"
}
},
"environment": {
"type": "object",
"description": "An optional map of environment variables. The key is the variable name (which must not be an empty string). Each variable is set regardless of whether or not a value was given to it by the process's environment. This field supports macro expansion, and environment variables in this map may reference each other, and may be listed in any order, as long as such references do not cause a cycle (for example,if ENV_1 is $env{ENV_2}, ENV_2 may not be $env{ENV_1}.) Environment variables are inherited through the inherits field, and the preset's environment will be the union of its own environment and the environment from all its parents. If multiple presets in this union define the same variable, the standard rules of inherits are applied. Setting a variable to null causes it to not be set, even if a value was inherited from another preset.",
"properties": {},
"additionalProperties": {
"anyOf": [
{
"type": "null",
"description": "Setting a variable to null causes it to not be set, even if a value was inherited from another preset."
},
{
"type": "string",
"description": "A string representing the value of the variable."
}
]
},
"propertyNames": {
"pattern": "^.+$"
}
},
"warnings": {
"type": "object",
"description": "An optional object specifying warnings.",
"properties": {
"dev": {
"type": "boolean",
"description": "An optional boolean. Equivalent to passing -Wdev or -Wno-dev on the command line. This may not be set to false if errors.dev is set to true."
},
"deprecated": {
"type": "boolean",
"description": "An optional boolean. Equivalent to passing -Wdeprecated or -Wno-deprecated on the command line. This may not be set to false if errors.deprecated is set to true."
},
"uninitialized": {
"type": "boolean",
"description": "An optional boolean. Setting this to true is equivalent to passing --warn-uninitialized on the command line."
},
"unusedCli": {
"type": "boolean",
"description": "An optional boolean. Setting this to false is equivalent to passing --no-warn-unused-cli on the command line."
},
"systemVars": {
"type": "boolean",
"description": "An optional boolean. Setting this to true is equivalent to passing --check-system-vars on the command line."
}
},
"additionalProperties": false
},
"errors": {
"type": "object",
"description": "An optional object specifying errors.",
"properties": {
"dev": {
"type": "boolean",
"description": "An optional boolean. Equivalent to passing -Werror=dev or -Wno-error=dev on the command line. This may not be set to true if warnings.dev is set to false."
},
"deprecated": {
"type": "boolean",
"description": "An optional boolean. Equivalent to passing -Werror=deprecated or -Wno-error=deprecated on the command line. This may not be set to true if warnings.deprecated is set to false."
}
},
"additionalProperties": false
},
"debug": {
"type": "object",
"description": "An optional object specifying debug options.",
"properties": {
"output": {
"type": "boolean",
"description": "An optional boolean. Setting this to true is equivalent to passing --debug-output on the command line."
},
"tryCompile": {
"type": "boolean",
"description": "An optional boolean. Setting this to true is equivalent to passing --debug-trycompile on the command line."
},
"find": {
"type": "boolean",
"description": "An optional boolean. Setting this to true is equivalent to passing --debug-find on the command line."
}
},
"additionalProperties": false
}
},
"required": [
"name"
],
"additionalProperties": false
}
}
},
"required": [
"version"
],
"additionalProperties": false
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment