cmake-presets.7.rst 50 KB

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