cmake-presets.7.rst 51 KB

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