1
0

cmake-presets.7.rst 50 KB

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