cmake-presets.7.rst 52 KB

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