cmake-presets.7.rst 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305
  1. .. cmake-manual-description: CMakePresets.json
  2. cmake-presets(7)
  3. ****************
  4. .. only:: html
  5. .. contents::
  6. Introduction
  7. ============
  8. .. versionadded:: 3.19
  9. One problem that CMake users often face is sharing settings with other people
  10. for common ways to configure a project. This may be done to support CI builds,
  11. or for users who frequently use the same build. CMake supports two main files,
  12. ``CMakePresets.json`` and ``CMakeUserPresets.json``, that allow users to
  13. specify common configure options and share them with others. CMake also
  14. supports files included with the ``include`` field.
  15. ``CMakePresets.json`` and ``CMakeUserPresets.json`` live in the project's root
  16. directory. They both have exactly the same format, and both are optional
  17. (though at least one must be present if :option:`--preset <cmake --preset>`
  18. is specified). ``CMakePresets.json`` is meant to specify project-wide build
  19. details, while ``CMakeUserPresets.json`` is meant for developers to specify
  20. their own local build details.
  21. ``CMakePresets.json`` may be checked into a version control system, and
  22. ``CMakeUserPresets.json`` should NOT be checked in. For example, if a
  23. project is using Git, ``CMakePresets.json`` may be tracked, and
  24. ``CMakeUserPresets.json`` should be added to the ``.gitignore``.
  25. Format
  26. ======
  27. The files are a JSON document with an object as the root:
  28. .. literalinclude:: presets/example.json
  29. :language: json
  30. Preset files specifying version ``10`` or above may include comments using the
  31. key ``$comment`` at any level within the JSON object to provide documentation.
  32. The root object recognizes the following fields:
  33. ``$schema``
  34. An optional string that provides a URI to the JSON schema that describes the
  35. structure of this JSON document. This field is used for validation and
  36. autocompletion in editors that support JSON schema. It doesn't affect the
  37. behavior of the document itself. If this field is not specified, the JSON
  38. document will still be valid, but tools that use JSON schema for validation
  39. and autocompletion may not function correctly.
  40. This is allowed in preset files specifying version ``8`` or above.
  41. ``version``
  42. A required integer representing the version of the JSON schema.
  43. The supported versions are:
  44. ``1``
  45. .. versionadded:: 3.19
  46. ``2``
  47. .. versionadded:: 3.20
  48. ``3``
  49. .. versionadded:: 3.21
  50. ``4``
  51. .. versionadded:: 3.23
  52. ``5``
  53. .. versionadded:: 3.24
  54. ``6``
  55. .. versionadded:: 3.25
  56. ``7``
  57. .. versionadded:: 3.27
  58. ``8``
  59. .. versionadded:: 3.28
  60. ``9``
  61. .. versionadded:: 3.30
  62. ``10``
  63. .. versionadded:: 3.31
  64. ``cmakeMinimumRequired``
  65. An optional object representing the minimum version of CMake needed to
  66. build this project. This object consists of the following fields:
  67. ``major``
  68. An optional integer representing the major version.
  69. ``minor``
  70. An optional integer representing the minor version.
  71. ``patch``
  72. An optional integer representing the patch version.
  73. ``include``
  74. An optional array of strings representing files to include. If the filenames
  75. are not absolute, they are considered relative to the current file.
  76. This is allowed in preset files specifying version ``4`` or above.
  77. See `Includes`_ for discussion of the constraints on included files.
  78. ``vendor``
  79. An optional map containing vendor-specific information. CMake does not
  80. interpret the contents of this field except to verify that it is a map if
  81. it does exist. However, the keys should be a vendor-specific domain name
  82. followed by a ``/``-separated path. For example, the Example IDE 1.0 could
  83. use ``example.com/ExampleIDE/1.0``. The value of each field can be anything
  84. desired by the vendor, though will typically be a map.
  85. ``configurePresets``
  86. An optional array of `Configure Preset`_ objects.
  87. This is allowed in preset files specifying version ``1`` or above.
  88. ``buildPresets``
  89. An optional array of `Build Preset`_ objects.
  90. This is allowed in preset files specifying version ``2`` or above.
  91. ``testPresets``
  92. An optional array of `Test Preset`_ objects.
  93. This is allowed in preset files specifying version ``2`` or above.
  94. ``packagePresets``
  95. An optional array of `Package Preset`_ objects.
  96. This is allowed in preset files specifying version ``6`` or above.
  97. ``workflowPresets``
  98. An optional array of `Workflow Preset`_ objects.
  99. This is allowed in preset files specifying version ``6`` or above.
  100. Includes
  101. ^^^^^^^^
  102. ``CMakePresets.json`` and ``CMakeUserPresets.json`` can include other files
  103. with the ``include`` field in file version ``4`` and later. Files included
  104. by these files can also include other files. If ``CMakePresets.json`` and
  105. ``CMakeUserPresets.json`` are both present, ``CMakeUserPresets.json``
  106. implicitly includes ``CMakePresets.json``, even with no ``include`` field,
  107. in all versions of the format.
  108. If a preset file contains presets that inherit from presets in another file,
  109. the file must include the other file either directly or indirectly.
  110. Include cycles are not allowed among files. If ``a.json`` includes
  111. ``b.json``, ``b.json`` cannot include ``a.json``. However, a file may be
  112. included multiple times from the same file or from different files.
  113. Files directly or indirectly included from ``CMakePresets.json`` should be
  114. guaranteed to be provided by the project. ``CMakeUserPresets.json`` may
  115. include files from anywhere.
  116. Starting from version ``7``, the ``include`` field supports
  117. `macro expansion`_, but only ``$penv{}`` macro expansion. Starting from version
  118. ``9``, other macro expansions are also available, except for ``$env{}`` and
  119. preset-specific macros, i.e., those derived from the fields inside a preset's
  120. definition like ``presetName``.
  121. Configure Preset
  122. ^^^^^^^^^^^^^^^^
  123. Each entry of the ``configurePresets`` array is a JSON object
  124. that may contain the following fields:
  125. ``name``
  126. A required string representing the machine-friendly name of the preset.
  127. This identifier is used in the :ref:`cmake --preset <CMake Options>` option.
  128. There must not be two configure presets in the union of ``CMakePresets.json``
  129. and ``CMakeUserPresets.json`` in the same directory with the same name.
  130. However, a configure preset may have the same name as a build, test,
  131. package, or workflow preset.
  132. ``hidden``
  133. An optional boolean specifying whether or not a preset should be hidden.
  134. If a preset is hidden, it cannot be used in the ``--preset=`` argument,
  135. will not show up in the :manual:`CMake GUI <cmake-gui(1)>`, and does not
  136. have to have a valid ``generator`` or ``binaryDir``, even from
  137. inheritance. ``hidden`` presets are intended to be used as a base for
  138. other presets to inherit via the ``inherits`` field.
  139. ``inherits``
  140. An optional array of strings representing the names of presets to inherit
  141. from. This field can also be a string, which is equivalent to an array
  142. containing one string.
  143. The preset will inherit all of the fields from the ``inherits``
  144. presets by default (except ``name``, ``hidden``, ``inherits``,
  145. ``description``, and ``displayName``), but can override them as
  146. desired. If multiple ``inherits`` presets provide conflicting values for
  147. the same field, the earlier preset in the ``inherits`` array will be
  148. preferred.
  149. A preset can only inherit from another preset that is defined in the
  150. same file or in one of the files it includes (directly or indirectly).
  151. Presets in ``CMakePresets.json`` may not inherit from presets in
  152. ``CMakeUserPresets.json``.
  153. ``condition``
  154. An optional `Condition`_ object. This is allowed in preset files specifying
  155. version ``3`` or above.
  156. ``vendor``
  157. An optional map containing vendor-specific information. CMake does not
  158. interpret the contents of this field except to verify that it is a map
  159. if it does exist. However, it should follow the same conventions as the
  160. root-level ``vendor`` field. If vendors use their own per-preset
  161. ``vendor`` field, they should implement inheritance in a sensible manner
  162. when appropriate.
  163. ``displayName``
  164. An optional string with a human-friendly name of the preset.
  165. ``description``
  166. An optional string with a human-friendly description of the preset.
  167. ``generator``
  168. An optional string representing the generator to use for the preset. If
  169. ``generator`` is not specified, it must be inherited from the
  170. ``inherits`` preset (unless this preset is ``hidden``). In version ``3``
  171. or above, this field may be omitted to fall back to regular generator
  172. discovery procedure.
  173. Note that for Visual Studio generators, unlike in the command line
  174. :option:`-G <cmake -G>` argument, you cannot include the platform name
  175. in the generator name. Use the ``architecture`` field instead.
  176. ``architecture``, ``toolset``
  177. Optional fields representing the platform and toolset, respectively, for
  178. :manual:`generators <cmake-generators(7)>` that support them.
  179. See :option:`cmake -A` option for possible values for ``architecture``
  180. and :option:`cmake -T` for ``toolset``.
  181. Each may be either a string or an object with the following fields:
  182. ``value``
  183. An optional string representing the value.
  184. ``strategy``
  185. An optional string telling CMake how to handle the ``architecture`` or
  186. ``toolset`` field. Valid values are:
  187. ``"set"``
  188. Set the respective value. This will result in an error for generators
  189. that do not support the respective field.
  190. ``"external"``
  191. Do not set the value, even if the generator supports it. This is
  192. useful if, for example, a preset uses the Ninja generator, and an IDE
  193. knows how to set up the Visual C++ environment from the
  194. ``architecture`` and ``toolset`` fields. In that case, CMake will
  195. ignore the field, but the IDE can use them to set up the environment
  196. before invoking CMake.
  197. If no ``strategy`` field is given, or if the field uses the string form
  198. rather than the object form, the behavior is the same as ``"set"``.
  199. ``toolchainFile``
  200. An optional string representing the path to the toolchain file.
  201. This field supports `macro expansion`_. If a relative path is specified,
  202. it is calculated relative to the build directory, and if not found,
  203. relative to the source directory. This field takes precedence over any
  204. :variable:`CMAKE_TOOLCHAIN_FILE` value. It is allowed in preset files
  205. specifying version ``3`` or above.
  206. ``graphviz``
  207. An optional string representing the path to the graphviz input file,
  208. that will contain all the library and executable dependencies
  209. in the project. See the documentation for :module:`CMakeGraphVizOptions`
  210. for more details.
  211. This field supports `macro expansion`_. If a relative path is specified,
  212. it is calculated relative to the current working directory. It is allowed
  213. in preset files specifying version ``10`` or above.
  214. ``binaryDir``
  215. An optional string representing the path to the output binary directory.
  216. This field supports `macro expansion`_. If a relative path is specified,
  217. it is calculated relative to the source directory. If ``binaryDir`` is not
  218. specified, it must be inherited from the ``inherits`` preset (unless this
  219. preset is ``hidden``). In version ``3`` or above, this field may be
  220. omitted.
  221. ``installDir``
  222. An optional string representing the path to the installation directory.
  223. This field supports `macro expansion`_. If a relative path is specified,
  224. it is calculated relative to the source directory. This is allowed in
  225. preset files specifying version ``3`` or above.
  226. ``cmakeExecutable``
  227. An optional string representing the path to the CMake executable to use
  228. for this preset. This is reserved for use by IDEs, and is not used by
  229. CMake itself. IDEs that use this field should expand any macros in it.
  230. ``cacheVariables``
  231. An optional map of cache variables. The key is the variable name (which
  232. may not be an empty string), and the value is either ``null``, a boolean
  233. (which is equivalent to a value of ``"TRUE"`` or ``"FALSE"`` and a type
  234. of ``BOOL``), a string representing the value of the variable (which
  235. supports `macro expansion`_), or an object with the following fields:
  236. ``type``
  237. An optional string representing the type of the variable.
  238. ``value``
  239. A required string or boolean representing the value of the variable.
  240. A boolean is equivalent to ``"TRUE"`` or ``"FALSE"``. This field
  241. supports `macro expansion`_.
  242. Cache variables are inherited through the ``inherits`` field, and the
  243. preset's variables will be the union of its own ``cacheVariables`` and
  244. the ``cacheVariables`` from all its parents. If multiple presets in this
  245. union define the same variable, the standard rules of ``inherits`` are
  246. applied. Setting a variable to ``null`` causes it to not be set, even if
  247. a value was inherited from another preset.
  248. ``environment``
  249. An optional map of environment variables. The key is the variable name
  250. (which may not be an empty string), and the value is either ``null`` or
  251. a string representing the value of the variable. Each variable is set
  252. regardless of whether or not a value was given to it by the process's
  253. environment. This field supports `macro expansion`_, and environment
  254. variables in this map may reference each other, and may be listed in any
  255. order, as long as such references do not cause a cycle (for example,
  256. if ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  257. Environment variables are inherited through the ``inherits`` field, and
  258. the preset's environment will be the union of its own ``environment`` and
  259. the ``environment`` from all its parents. If multiple presets in this
  260. union define the same variable, the standard rules of ``inherits`` are
  261. applied. Setting a variable to ``null`` causes it to not be set, even if
  262. a value was inherited from another preset.
  263. ``warnings``
  264. An optional object specifying the warnings to enable. The object may
  265. contain the following fields:
  266. ``dev``
  267. An optional boolean. Equivalent to passing :option:`-Wdev <cmake -Wdev>`
  268. or :option:`-Wno-dev <cmake -Wno-dev>` on the command line. This may not
  269. be set to ``false`` if ``errors.dev`` is set to ``true``.
  270. ``deprecated``
  271. An optional boolean. Equivalent to passing
  272. :option:`-Wdeprecated <cmake -Wdeprecated>` or
  273. :option:`-Wno-deprecated <cmake -Wno-deprecated>` on the command line.
  274. This may not be set to ``false`` if ``errors.deprecated`` is set to
  275. ``true``.
  276. ``uninitialized``
  277. An optional boolean. Setting this to ``true`` is equivalent to passing
  278. :option:`--warn-uninitialized <cmake --warn-uninitialized>` on the command
  279. line.
  280. ``unusedCli``
  281. An optional boolean. Setting this to ``false`` is equivalent to passing
  282. :option:`--no-warn-unused-cli <cmake --no-warn-unused-cli>` on the command
  283. line.
  284. ``systemVars``
  285. An optional boolean. Setting this to ``true`` is equivalent to passing
  286. :option:`--check-system-vars <cmake --check-system-vars>` on the command
  287. line.
  288. ``errors``
  289. An optional object specifying the errors to enable. The object may
  290. contain the following fields:
  291. ``dev``
  292. An optional boolean. Equivalent to passing :option:`-Werror=dev <cmake -Werror>`
  293. or :option:`-Wno-error=dev <cmake -Werror>` on the command line.
  294. This may not be set to ``true`` if ``warnings.dev`` is set to ``false``.
  295. ``deprecated``
  296. An optional boolean. Equivalent to passing
  297. :option:`-Werror=deprecated <cmake -Werror>` or
  298. :option:`-Wno-error=deprecated <cmake -Werror>` on the command line.
  299. This may not be set to ``true`` if ``warnings.deprecated`` is set to
  300. ``false``.
  301. ``debug``
  302. An optional object specifying debug options. The object may contain the
  303. following fields:
  304. ``output``
  305. An optional boolean. Setting this to ``true`` is equivalent to passing
  306. :option:`--debug-output <cmake --debug-output>` on the command line.
  307. ``tryCompile``
  308. An optional boolean. Setting this to ``true`` is equivalent to passing
  309. :option:`--debug-trycompile <cmake --debug-trycompile>` on the command
  310. line.
  311. ``find``
  312. An optional boolean. Setting this to ``true`` is equivalent to passing
  313. :option:`--debug-find <cmake --debug-find>` on the command line.
  314. ``trace``
  315. An optional object specifying trace options. This is allowed in preset
  316. files specifying version ``7``. The object may contain the following fields:
  317. ``mode``
  318. An optional string that specifies the trace mode. Valid values are:
  319. ``on``
  320. Causes a trace of all calls made and from where to be printed.
  321. Equivalent to passing :option:`--trace <cmake --trace>` on the command
  322. line.
  323. ``off``
  324. A trace of all calls will not be printed.
  325. ``expand``
  326. Causes a trace with variables expanded of all calls made and from where
  327. to be printed. Equivalent to passing :option:`--trace-expand <cmake --trace-expand>`
  328. on the command line.
  329. ``format``
  330. An optional string that specifies the format output of the trace.
  331. Valid values are:
  332. ``human``
  333. Prints each trace line in a human-readable format.
  334. This is the default format. Equivalent to passing
  335. :option:`--trace-format=human <cmake --trace-format>`
  336. on the command line.
  337. ``json-v1``
  338. Prints each line as a separate JSON document. Equivalent to passing
  339. :option:`--trace-format=json-v1 <cmake --trace-format>`
  340. on the command line.
  341. ``source``
  342. An optional array of strings representing the paths of source files to
  343. be traced. This field can also be a string, which is equivalent to an
  344. array containing one string. Equivalent to passing
  345. :option:`--trace-source <cmake --trace-source>` on the command line.
  346. ``redirect``
  347. An optional string specifying a path to a trace output file. Equivalent
  348. to passing :option:`--trace-redirect <cmake --trace-redirect>`
  349. on the command line.
  350. Build Preset
  351. ^^^^^^^^^^^^
  352. Each entry of the ``buildPresets`` array is a JSON object
  353. that may contain the following fields:
  354. ``name``
  355. A required string representing the machine-friendly name of the preset.
  356. This identifier is used in the
  357. :ref:`cmake --build --preset <Build Tool Mode>` option.
  358. There must not be two build presets in the union of ``CMakePresets.json``
  359. and ``CMakeUserPresets.json`` in the same directory with the same name.
  360. However, a build preset may have the same name as a configure, test,
  361. package, or workflow preset.
  362. ``hidden``
  363. An optional boolean specifying whether or not a preset should be hidden.
  364. If a preset is hidden, it cannot be used in the
  365. :option:`--preset <cmake --preset>` argument
  366. and does not have to have a valid ``configurePreset``, even from
  367. inheritance. ``hidden`` presets are intended to be used as a base for
  368. other presets to inherit via the ``inherits`` field.
  369. ``inherits``
  370. An optional array of strings representing the names of presets to inherit
  371. from. This field can also be a string, which is equivalent to an array
  372. containing one string.
  373. The preset will inherit all of the fields from the
  374. ``inherits`` presets by default (except ``name``, ``hidden``,
  375. ``inherits``, ``description``, and ``displayName``), but can override
  376. them as desired. If multiple ``inherits`` presets provide conflicting
  377. values for the same field, the earlier preset in the ``inherits`` array
  378. will be preferred.
  379. A preset can only inherit from another preset that is defined in the
  380. same file or in one of the files it includes (directly or indirectly).
  381. Presets in ``CMakePresets.json`` may not inherit from presets in
  382. ``CMakeUserPresets.json``.
  383. ``condition``
  384. An optional `Condition`_ object. This is allowed in preset files specifying
  385. version ``3`` or above.
  386. ``vendor``
  387. An optional map containing vendor-specific information. CMake does not
  388. interpret the contents of this field except to verify that it is a map
  389. if it does exist. However, it should follow the same conventions as the
  390. root-level ``vendor`` field. If vendors use their own per-preset
  391. ``vendor`` field, they should implement inheritance in a sensible manner
  392. when appropriate.
  393. ``displayName``
  394. An optional string with a human-friendly name of the preset.
  395. ``description``
  396. An optional string with a human-friendly description of the preset.
  397. ``environment``
  398. An optional map of environment variables. The key is the variable name
  399. (which may not be an empty string), and the value is either ``null`` or
  400. a string representing the value of the variable. Each variable is set
  401. regardless of whether or not a value was given to it by the process's
  402. environment. This field supports macro expansion, and environment
  403. variables in this map may reference each other, and may be listed in any
  404. order, as long as such references do not cause a cycle (for example, if
  405. ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  406. Environment variables are inherited through the ``inherits`` field, and
  407. the preset's environment will be the union of its own ``environment``
  408. and the ``environment`` from all its parents. If multiple presets in
  409. this union define the same variable, the standard rules of ``inherits``
  410. are applied. Setting a variable to ``null`` causes it to not be set,
  411. even if a value was inherited from another preset.
  412. .. note::
  413. For a CMake project using ExternalProject with a configuration preset
  414. having environment variables needed in the ExternalProject, use a build
  415. preset that inherits that configuration preset or the ExternalProject
  416. will not have the environment variables set in the configuration preset.
  417. Example: suppose the host defaults to one compiler (say Clang)
  418. and the user wishes to use another compiler (say GCC). Set configuration
  419. preset environment variables ``CC`` and ``CXX`` and use a build preset
  420. that inherits that configuration preset. Otherwise the ExternalProject
  421. may use a different (system default) compiler than the top-level CMake
  422. project.
  423. ``configurePreset``
  424. An optional string specifying the name of a configure preset to
  425. associate with this build preset. If ``configurePreset`` is not
  426. specified, it must be inherited from the inherits preset (unless this
  427. preset is hidden). The build directory is inferred from the configure
  428. preset, so the build will take place in the same ``binaryDir`` that the
  429. configuration did.
  430. ``inheritConfigureEnvironment``
  431. An optional boolean that defaults to true. If true, the environment
  432. variables from the associated configure preset are inherited after all
  433. inherited build preset environments, but before environment variables
  434. explicitly specified in this build preset.
  435. ``jobs``
  436. An optional integer. Equivalent to passing
  437. :option:`--parallel <cmake--build --parallel>` or ``-j`` on the command line.
  438. ``targets``
  439. An optional string or array of strings. Equivalent to passing
  440. :option:`--target <cmake--build --target>` or ``-t`` on the command line.
  441. Vendors may ignore the targets property or hide build presets that
  442. explicitly specify targets. This field supports macro expansion.
  443. ``configuration``
  444. An optional string. Equivalent to passing
  445. :option:`--config <cmake--build --config>` on the command line.
  446. ``cleanFirst``
  447. An optional bool. If true, equivalent to passing
  448. :option:`--clean-first <cmake--build --clean-first>` on the command line.
  449. ``resolvePackageReferences``
  450. An optional string that specifies the package resolve mode. This is
  451. allowed in preset files specifying version ``4`` or above.
  452. Package references are used to define dependencies to packages from
  453. external package managers. Currently only NuGet in combination with the
  454. Visual Studio generator is supported. If there are no targets that define
  455. package references, this option does nothing. Valid values are:
  456. ``on``
  457. Causes package references to be resolved before attempting a build.
  458. ``off``
  459. Package references will not be resolved. Note that this may cause
  460. errors in some build environments, such as .NET SDK style projects.
  461. ``only``
  462. Only resolve package references, but do not perform a build.
  463. .. note::
  464. The command line parameter
  465. :option:`--resolve-package-references <cmake--build --resolve-package-references>`
  466. will take priority over this setting. If the command line parameter is not
  467. provided and this setting is not specified, an environment-specific cache
  468. variable will be evaluated to decide, if package restoration should be
  469. performed.
  470. When using the Visual Studio generator, package references are defined
  471. using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references
  472. are restored using NuGet. It can be disabled by setting the
  473. ``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to ``OFF``. This can also be
  474. done from within a configure preset.
  475. ``verbose``
  476. An optional bool. If true, equivalent to passing
  477. :option:`--verbose <cmake--build --verbose>` on the command line.
  478. ``nativeToolOptions``
  479. An optional array of strings. Equivalent to passing options after ``--``
  480. on the command line. The array values support macro expansion.
  481. Test Preset
  482. ^^^^^^^^^^^
  483. Each entry of the ``testPresets`` array is a JSON object
  484. that may contain the following fields:
  485. ``name``
  486. A required string representing the machine-friendly name of the preset.
  487. This identifier is used in the :option:`ctest --preset` option.
  488. There must not be two test presets in the union of ``CMakePresets.json``
  489. and ``CMakeUserPresets.json`` in the same directory with the same name.
  490. However, a test preset may have the same name as a configure, build,
  491. package, or workflow preset.
  492. ``hidden``
  493. An optional boolean specifying whether or not a preset should be hidden.
  494. If a preset is hidden, it cannot be used in the
  495. :option:`--preset <ctest --preset>` argument
  496. and does not have to have a valid ``configurePreset``, even from
  497. inheritance. ``hidden`` presets are intended to be used as a base for
  498. other presets to inherit via the ``inherits`` field.
  499. ``inherits``
  500. An optional array of strings representing the names of presets to inherit
  501. from. This field can also be a string, which is equivalent to an array
  502. containing one string.
  503. The preset will inherit all of the fields from the
  504. ``inherits`` presets by default (except ``name``, ``hidden``,
  505. ``inherits``, ``description``, and ``displayName``), but can override
  506. them as desired. If multiple ``inherits`` presets provide conflicting
  507. values for the same field, the earlier preset in the ``inherits`` array
  508. will be preferred.
  509. A preset can only inherit from another preset that is defined in the
  510. same file or in one of the files it includes (directly or indirectly).
  511. Presets in ``CMakePresets.json`` may not inherit from presets in
  512. ``CMakeUserPresets.json``.
  513. ``condition``
  514. An optional `Condition`_ object. This is allowed in preset files specifying
  515. version ``3`` or above.
  516. ``vendor``
  517. An optional map containing vendor-specific information. CMake does not
  518. interpret the contents of this field except to verify that it is a map
  519. if it does exist. However, it should follow the same conventions as the
  520. root-level ``vendor`` field. If vendors use their own per-preset
  521. ``vendor`` field, they should implement inheritance in a sensible manner
  522. when appropriate.
  523. ``displayName``
  524. An optional string with a human-friendly name of the preset.
  525. ``description``
  526. An optional string with a human-friendly description of the preset.
  527. ``environment``
  528. An optional map of environment variables. The key is the variable name
  529. (which may not be an empty string), and the value is either ``null`` or
  530. a string representing the value of the variable. Each variable is set
  531. regardless of whether or not a value was given to it by the process's
  532. environment. This field supports macro expansion, and environment
  533. variables in this map may reference each other, and may be listed in any
  534. order, as long as such references do not cause a cycle (for example, if
  535. ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  536. Environment variables are inherited through the ``inherits`` field, and
  537. the preset's environment will be the union of its own ``environment``
  538. and the ``environment`` from all its parents. If multiple presets in
  539. this union define the same variable, the standard rules of ``inherits``
  540. are applied. Setting a variable to ``null`` causes it to not be set,
  541. even if a value was inherited from another preset.
  542. ``configurePreset``
  543. An optional string specifying the name of a configure preset to
  544. associate with this test preset. If ``configurePreset`` is not
  545. specified, it must be inherited from the inherits preset (unless this
  546. preset is hidden). The build directory is inferred from the configure
  547. preset, so tests will run in the same ``binaryDir`` that the
  548. configuration did and build did.
  549. ``inheritConfigureEnvironment``
  550. An optional boolean that defaults to true. If true, the environment
  551. variables from the associated configure preset are inherited after all
  552. inherited test preset environments, but before environment variables
  553. explicitly specified in this test preset.
  554. ``configuration``
  555. An optional string. Equivalent to passing
  556. :option:`--build-config <ctest --build-config>` on the command line.
  557. ``overwriteConfigurationFile``
  558. An optional array of configuration options to overwrite options
  559. specified in the CTest configuration file. Equivalent to passing
  560. :option:`--overwrite <ctest --overwrite>` for each value in the array.
  561. The array values support macro expansion.
  562. ``output``
  563. An optional object specifying output options. The object may contain the
  564. following fields.
  565. ``shortProgress``
  566. An optional bool. If true, equivalent to passing
  567. :option:`--progress <ctest --progress>` on the command line.
  568. ``verbosity``
  569. An optional string specifying verbosity level. Must be one of the
  570. following:
  571. ``default``
  572. Equivalent to passing no verbosity flags on the command line.
  573. ``verbose``
  574. Equivalent to passing :option:`--verbose <ctest --verbose>` on
  575. the command line.
  576. ``extra``
  577. Equivalent to passing :option:`--extra-verbose <ctest --extra-verbose>`
  578. on the command line.
  579. ``debug``
  580. An optional bool. If true, equivalent to passing
  581. :option:`--debug <ctest --debug>` on the command line.
  582. ``outputOnFailure``
  583. An optional bool. If true, equivalent to passing
  584. :option:`--output-on-failure <ctest --output-on-failure>` on the command
  585. line.
  586. ``quiet``
  587. An optional bool. If true, equivalent to passing
  588. :option:`--quiet <ctest --quiet>` on the command line.
  589. ``outputLogFile``
  590. An optional string specifying a path to a log file. Equivalent to
  591. passing :option:`--output-log <ctest --output-log>` on the command line.
  592. This field supports macro expansion.
  593. ``outputJUnitFile``
  594. An optional string specifying a path to a JUnit file. Equivalent to
  595. passing :option:`--output-junit <ctest --output-junit>` on the command line.
  596. This field supports macro expansion. This is allowed in preset files
  597. specifying version ``6`` or above.
  598. ``labelSummary``
  599. An optional bool. If false, equivalent to passing
  600. :option:`--no-label-summary <ctest --no-label-summary>` on the command
  601. line.
  602. ``subprojectSummary``
  603. An optional bool. If false, equivalent to passing
  604. :option:`--no-subproject-summary <ctest --no-subproject-summary>`
  605. on the command line.
  606. ``maxPassedTestOutputSize``
  607. An optional integer specifying the maximum output for passed tests in
  608. bytes. Equivalent to passing
  609. :option:`--test-output-size-passed <ctest --test-output-size-passed>`
  610. on the command line.
  611. ``maxFailedTestOutputSize``
  612. An optional integer specifying the maximum output for failed tests in
  613. bytes. Equivalent to passing
  614. :option:`--test-output-size-failed <ctest --test-output-size-failed>`
  615. on the command line.
  616. ``testOutputTruncation``
  617. An optional string specifying the test output truncation mode. Equivalent
  618. to passing
  619. :option:`--test-output-truncation <ctest --test-output-truncation>` on
  620. the command line. This is allowed in preset files specifying version
  621. ``5`` or above.
  622. ``maxTestNameWidth``
  623. An optional integer specifying the maximum width of a test name to
  624. output. Equivalent to passing :option:`--max-width <ctest --max-width>`
  625. on the command line.
  626. ``filter``
  627. An optional object specifying how to filter the tests to run. The object
  628. may contain the following fields.
  629. ``include``
  630. An optional object specifying which tests to include. The object may
  631. contain the following fields.
  632. ``name``
  633. An optional string specifying a regex for test names. Equivalent to
  634. passing :option:`--tests-regex <ctest --tests-regex>` on the command
  635. line. This field supports macro expansion. CMake regex syntax is
  636. described under :ref:`string(REGEX) <Regex Specification>`.
  637. ``label``
  638. An optional string specifying a regex for test labels. Equivalent to
  639. passing :option:`--label-regex <ctest --label-regex>` on the command
  640. line. This field supports macro expansion.
  641. ``useUnion``
  642. An optional bool. Equivalent to passing :option:`--union <ctest --union>`
  643. on the command line.
  644. ``index``
  645. An optional object specifying tests to include by test index. The
  646. object may contain the following fields. Can also be an optional
  647. string specifying a file with the command line syntax for
  648. :option:`--tests-information <ctest --tests-information>`.
  649. If specified as a string, this field supports macro expansion.
  650. ``start``
  651. An optional integer specifying a test index to start testing at.
  652. ``end``
  653. An optional integer specifying a test index to stop testing at.
  654. ``stride``
  655. An optional integer specifying the increment.
  656. ``specificTests``
  657. An optional array of integers specifying specific test indices to
  658. run.
  659. ``exclude``
  660. An optional object specifying which tests to exclude. The object may
  661. contain the following fields.
  662. ``name``
  663. An optional string specifying a regex for test names. Equivalent to
  664. passing :option:`--exclude-regex <ctest --exclude-regex>` on the
  665. command line. This field supports macro expansion.
  666. ``label``
  667. An optional string specifying a regex for test labels. Equivalent to
  668. passing :option:`--label-exclude <ctest --label-exclude>` on the
  669. command line. This field supports macro expansion.
  670. ``fixtures``
  671. An optional object specifying which fixtures to exclude from adding
  672. tests. The object may contain the following fields.
  673. ``any``
  674. An optional string specifying a regex for text fixtures to exclude
  675. from adding any tests. Equivalent to
  676. :option:`--fixture-exclude-any <ctest --fixture-exclude-any>` on
  677. the command line. This field supports macro expansion.
  678. ``setup``
  679. An optional string specifying a regex for text fixtures to exclude
  680. from adding setup tests. Equivalent to
  681. :option:`--fixture-exclude-setup <ctest --fixture-exclude-setup>`
  682. on the command line. This field supports macro expansion.
  683. ``cleanup``
  684. An optional string specifying a regex for text fixtures to exclude
  685. from adding cleanup tests. Equivalent to
  686. :option:`--fixture-exclude-cleanup <ctest --fixture-exclude-cleanup>`
  687. on the command line. This field supports macro expansion.
  688. ``execution``
  689. An optional object specifying options for test execution. The object may
  690. contain the following fields.
  691. ``stopOnFailure``
  692. An optional bool. If true, equivalent to passing
  693. :option:`--stop-on-failure <ctest --stop-on-failure>` on the command
  694. line.
  695. ``enableFailover``
  696. An optional bool. If true, equivalent to passing :option:`-F <ctest -F>`
  697. on the command line.
  698. ``jobs``
  699. An optional integer. Equivalent to passing
  700. :option:`--parallel <ctest --parallel>` on the command line.
  701. ``resourceSpecFile``
  702. An optional string. Equivalent to passing
  703. :option:`--resource-spec-file <ctest --resource-spec-file>` on
  704. the command line. This field supports macro expansion.
  705. ``testLoad``
  706. An optional integer. Equivalent to passing
  707. :option:`--test-load <ctest --test-load>` on the command line.
  708. ``showOnly``
  709. An optional string. Equivalent to passing
  710. :option:`--show-only <ctest --show-only>` on the
  711. command line. The string must be one of the following values:
  712. ``human``
  713. ``json-v1``
  714. ``repeat``
  715. An optional object specifying how to repeat tests. Equivalent to
  716. passing :option:`--repeat <ctest --repeat>` on the command line.
  717. The object must have the following fields.
  718. ``mode``
  719. A required string. Must be one of the following values:
  720. ``until-fail``
  721. ``until-pass``
  722. ``after-timeout``
  723. ``count``
  724. A required integer.
  725. ``interactiveDebugging``
  726. An optional bool. If true, equivalent to passing
  727. :option:`--interactive-debug-mode 1 <ctest --interactive-debug-mode>`
  728. on the command line. If false, equivalent to passing
  729. :option:`--interactive-debug-mode 0 <ctest --interactive-debug-mode>`
  730. on the command line.
  731. ``scheduleRandom``
  732. An optional bool. If true, equivalent to passing
  733. :option:`--schedule-random <ctest --schedule-random>` on the command
  734. line.
  735. ``timeout``
  736. An optional integer. Equivalent to passing
  737. :option:`--timeout <ctest --timeout>` on the command line.
  738. ``noTestsAction``
  739. An optional string specifying the behavior if no tests are found. Must
  740. be one of the following values:
  741. ``default``
  742. Equivalent to not passing any value on the command line.
  743. ``error``
  744. Equivalent to passing :option:`--no-tests=error <ctest --no-tests>`
  745. on the command line.
  746. ``ignore``
  747. Equivalent to passing :option:`--no-tests=ignore <ctest --no-tests>`
  748. on the command line.
  749. Package Preset
  750. ^^^^^^^^^^^^^^
  751. Package presets may be used in schema version ``6`` or above. Each entry of
  752. the ``packagePresets`` array is a JSON object that may contain the following
  753. fields:
  754. ``name``
  755. A required string representing the machine-friendly name of the preset.
  756. This identifier is used in the :option:`cpack --preset` option.
  757. There must not be two package presets in the union of ``CMakePresets.json``
  758. and ``CMakeUserPresets.json`` in the same directory with the same name.
  759. However, a package preset may have the same name as a configure, build,
  760. test, or workflow preset.
  761. ``hidden``
  762. An optional boolean specifying whether or not a preset should be hidden.
  763. If a preset is hidden, it cannot be used in the
  764. :option:`--preset <cpack --preset>` argument
  765. and does not have to have a valid ``configurePreset``, even from
  766. inheritance. ``hidden`` presets are intended to be used as a base for
  767. other presets to inherit via the ``inherits`` field.
  768. ``inherits``
  769. An optional array of strings representing the names of presets to inherit
  770. from. This field can also be a string, which is equivalent to an array
  771. containing one string.
  772. The preset will inherit all of the fields from the
  773. ``inherits`` presets by default (except ``name``, ``hidden``,
  774. ``inherits``, ``description``, and ``displayName``), but can override
  775. them as desired. If multiple ``inherits`` presets provide conflicting
  776. values for the same field, the earlier preset in the ``inherits`` array
  777. will be preferred.
  778. A preset can only inherit from another preset that is defined in the
  779. same file or in one of the files it includes (directly or indirectly).
  780. Presets in ``CMakePresets.json`` may not inherit from presets in
  781. ``CMakeUserPresets.json``.
  782. ``condition``
  783. An optional `Condition`_ object.
  784. ``vendor``
  785. An optional map containing vendor-specific information. CMake does not
  786. interpret the contents of this field except to verify that it is a map
  787. if it does exist. However, it should follow the same conventions as the
  788. root-level ``vendor`` field. If vendors use their own per-preset
  789. ``vendor`` field, they should implement inheritance in a sensible manner
  790. when appropriate.
  791. ``displayName``
  792. An optional string with a human-friendly name of the preset.
  793. ``description``
  794. An optional string with a human-friendly description of the preset.
  795. ``environment``
  796. An optional map of environment variables. The key is the variable name
  797. (which may not be an empty string), and the value is either ``null`` or
  798. a string representing the value of the variable. Each variable is set
  799. regardless of whether or not a value was given to it by the process's
  800. environment. This field supports macro expansion, and environment
  801. variables in this map may reference each other, and may be listed in any
  802. order, as long as such references do not cause a cycle (for example, if
  803. ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  804. Environment variables are inherited through the ``inherits`` field, and
  805. the preset's environment will be the union of its own ``environment``
  806. and the ``environment`` from all its parents. If multiple presets in
  807. this union define the same variable, the standard rules of ``inherits``
  808. are applied. Setting a variable to ``null`` causes it to not be set,
  809. even if a value was inherited from another preset.
  810. ``configurePreset``
  811. An optional string specifying the name of a configure preset to
  812. associate with this package preset. If ``configurePreset`` is not
  813. specified, it must be inherited from the inherits preset (unless this
  814. preset is hidden). The build directory is inferred from the configure
  815. preset, so packaging will run in the same ``binaryDir`` that the
  816. configuration did and build did.
  817. ``inheritConfigureEnvironment``
  818. An optional boolean that defaults to true. If true, the environment
  819. variables from the associated configure preset are inherited after all
  820. inherited package preset environments, but before environment variables
  821. explicitly specified in this package preset.
  822. ``generators``
  823. An optional array of strings representing generators for CPack to use.
  824. ``configurations``
  825. An optional array of strings representing build configurations for CPack to
  826. package.
  827. ``variables``
  828. An optional map of variables to pass to CPack, equivalent to
  829. :option:`-D <cpack -D>` arguments. Each key is the name of a variable, and
  830. the value is the string to assign to that variable.
  831. ``configFile``
  832. An optional string representing the config file for CPack to use.
  833. ``output``
  834. An optional object specifying output options. Valid keys are:
  835. ``debug``
  836. An optional boolean specifying whether or not to print debug information.
  837. A value of ``true`` is equivalent to passing
  838. :option:`--debug <cpack --debug>` on the command line.
  839. ``verbose``
  840. An optional boolean specifying whether or not to print verbosely. A value
  841. of ``true`` is equivalent to passing :option:`--verbose <cpack --verbose>`
  842. on the command line.
  843. ``packageName``
  844. An optional string representing the package name.
  845. ``packageVersion``
  846. An optional string representing the package version.
  847. ``packageDirectory``
  848. An optional string representing the directory in which to place the package.
  849. ``vendorName``
  850. An optional string representing the vendor name.
  851. .. _`Workflow Preset`:
  852. Workflow Preset
  853. ^^^^^^^^^^^^^^^
  854. Workflow presets may be used in schema version ``6`` or above. Each entry of
  855. the ``workflowPresets`` array is a JSON object that may contain the following
  856. fields:
  857. ``name``
  858. A required string representing the machine-friendly name of the preset.
  859. This identifier is used in the
  860. :ref:`cmake --workflow --preset <Workflow Mode>` option. There must not be
  861. two workflow presets in the union of ``CMakePresets.json`` and
  862. ``CMakeUserPresets.json`` in the same directory with the same name. However,
  863. a workflow preset may have the same name as a configure, build, test, or
  864. package preset.
  865. ``vendor``
  866. An optional map containing vendor-specific information. CMake does not
  867. interpret the contents of this field except to verify that it is a map
  868. if it does exist. However, it should follow the same conventions as the
  869. root-level ``vendor`` field.
  870. ``displayName``
  871. An optional string with a human-friendly name of the preset.
  872. ``description``
  873. An optional string with a human-friendly description of the preset.
  874. ``steps``
  875. A required array of objects describing the steps of the workflow. The first
  876. step must be a configure preset, and all subsequent steps must be non-
  877. configure presets whose ``configurePreset`` field matches the starting
  878. configure preset. Each object may contain the following fields:
  879. ``type``
  880. A required string. The first step must be ``configure``. Subsequent steps
  881. must be either ``build``, ``test``, or ``package``.
  882. ``name``
  883. A required string representing the name of the configure, build, test, or
  884. package preset to run as this workflow step.
  885. Condition
  886. ^^^^^^^^^
  887. The ``condition`` field of a preset, allowed in preset files specifying version
  888. ``3`` or above, is used to determine whether or not the preset is enabled. For
  889. example, this can be used to disable a preset on platforms other than Windows.
  890. ``condition`` may be either a boolean, ``null``, or an object. If it is a
  891. boolean, the boolean indicates whether the preset is enabled or disabled. If it
  892. is ``null``, the preset is enabled, but the ``null`` condition is not inherited
  893. by any presets that may inherit from the preset. Sub-conditions (for example in
  894. a ``not``, ``anyOf``, or ``allOf`` condition) may not be ``null``. If it is an
  895. object, it has the following fields:
  896. ``type``
  897. A required string with one of the following values:
  898. ``"const"``
  899. Indicates that the condition is constant. This is equivalent to using a
  900. boolean in place of the object. The condition object will have the
  901. following additional fields:
  902. ``value``
  903. A required boolean which provides a constant value for the condition's
  904. evaluation.
  905. ``"equals"``
  906. ``"notEquals"``
  907. Indicates that the condition compares two strings to see if they are equal
  908. (or not equal). The condition object will have the following additional
  909. fields:
  910. ``lhs``
  911. First string to compare. This field supports macro expansion.
  912. ``rhs``
  913. Second string to compare. This field supports macro expansion.
  914. ``"inList"``
  915. ``"notInList"``
  916. Indicates that the condition searches for a string in a list of strings.
  917. The condition object will have the following additional fields:
  918. ``string``
  919. A required string to search for. This field supports macro expansion.
  920. ``list``
  921. A required array of strings to search. This field supports macro
  922. expansion, and uses short-circuit evaluation.
  923. ``"matches"``
  924. ``"notMatches"``
  925. Indicates that the condition searches for a regular expression in a string.
  926. The condition object will have the following additional fields:
  927. ``string``
  928. A required string to search. This field supports macro expansion.
  929. ``regex``
  930. A required regular expression to search for. This field supports macro
  931. expansion.
  932. ``"anyOf"``
  933. ``"allOf"``
  934. Indicates that the condition is an aggregation of zero or more nested
  935. conditions. The condition object will have the following additional fields:
  936. ``conditions``
  937. A required array of condition objects. These conditions use short-circuit
  938. evaluation.
  939. ``"not"``
  940. Indicates that the condition is an inversion of another condition. The
  941. condition object will have the following additional fields:
  942. ``condition``
  943. A required condition object.
  944. Macro Expansion
  945. ^^^^^^^^^^^^^^^
  946. As mentioned above, some fields support macro expansion. Macros are
  947. recognized in the form ``$<macro-namespace>{<macro-name>}``. All macros are
  948. evaluated in the context of the preset being used, even if the macro is in a
  949. field that was inherited from another preset. For example, if the ``Base``
  950. preset sets variable ``PRESET_NAME`` to ``${presetName}``, and the
  951. ``Derived`` preset inherits from ``Base``, ``PRESET_NAME`` will be set to
  952. ``Derived``.
  953. It is an error to not put a closing brace at the end of a macro name. For
  954. example, ``${sourceDir`` is invalid. A dollar sign (``$``) followed by
  955. anything other than a left curly brace (``{``) with a possible namespace is
  956. interpreted as a literal dollar sign.
  957. Recognized macros include:
  958. ``${sourceDir}``
  959. Path to the project source directory (i.e. the same as
  960. :variable:`CMAKE_SOURCE_DIR`).
  961. ``${sourceParentDir}``
  962. Path to the project source directory's parent directory.
  963. ``${sourceDirName}``
  964. The last filename component of ``${sourceDir}``. For example, if
  965. ``${sourceDir}`` is ``/path/to/source``, this would be ``source``.
  966. ``${presetName}``
  967. Name specified in the preset's ``name`` field.
  968. This is a preset-specific macro.
  969. ``${generator}``
  970. Generator specified in the preset's ``generator`` field. For build and
  971. test presets, this will evaluate to the generator specified by
  972. ``configurePreset``.
  973. This is a preset-specific macro.
  974. ``${hostSystemName}``
  975. The name of the host operating system. Contains the same value as
  976. :variable:`CMAKE_HOST_SYSTEM_NAME`. This is allowed in preset files
  977. specifying version ``3`` or above.
  978. ``${fileDir}``
  979. Path to the directory containing the preset file which contains the macro.
  980. This is allowed in preset files specifying version ``4`` or above.
  981. ``${dollar}``
  982. A literal dollar sign (``$``).
  983. ``${pathListSep}``
  984. Native character for separating lists of paths, such as ``:`` or ``;``.
  985. For example, by setting ``PATH`` to
  986. ``/path/to/ninja/bin${pathListSep}$env{PATH}``, ``${pathListSep}`` will
  987. expand to the underlying operating system's character used for
  988. concatenation in ``PATH``.
  989. This is allowed in preset files specifying version ``5`` or above.
  990. ``$env{<variable-name>}``
  991. Environment variable with name ``<variable-name>``. The variable name may
  992. not be an empty string. If the variable is defined in the ``environment``
  993. field, that value is used instead of the value from the parent environment.
  994. If the environment variable is not defined, this evaluates as an empty
  995. string.
  996. Note that while Windows environment variable names are case-insensitive,
  997. variable names within a preset are still case-sensitive. This may lead to
  998. unexpected results when using inconsistent casing. For best results, keep
  999. the casing of environment variable names consistent.
  1000. ``$penv{<variable-name>}``
  1001. Similar to ``$env{<variable-name>}``, except that the value only comes from
  1002. the parent environment, and never from the ``environment`` field. This
  1003. allows you to prepend or append values to existing environment variables.
  1004. For example, setting ``PATH`` to ``/path/to/ninja/bin:$penv{PATH}`` will
  1005. prepend ``/path/to/ninja/bin`` to the ``PATH`` environment variable. This
  1006. is needed because ``$env{<variable-name>}`` does not allow circular
  1007. references.
  1008. ``$vendor{<macro-name>}``
  1009. An extension point for vendors to insert their own macros. CMake will not
  1010. be able to use presets which have a ``$vendor{<macro-name>}`` macro, and
  1011. effectively ignores such presets. However, it will still be able to use
  1012. other presets from the same file.
  1013. CMake does not make any attempt to interpret ``$vendor{<macro-name>}``
  1014. macros. However, to avoid name collisions, IDE vendors should prefix
  1015. ``<macro-name>`` with a very short (preferably <= 4 characters) vendor
  1016. identifier prefix, followed by a ``.``, followed by the macro name. For
  1017. example, the Example IDE could have ``$vendor{xide.ideInstallDir}``.
  1018. Schema
  1019. ======
  1020. :download:`This file </manual/presets/schema.json>` provides a machine-readable
  1021. JSON schema for the ``CMakePresets.json`` format.