cmake-presets.7.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. .. cmake-manual-description: CMakePresets.json
  2. cmake-presets(7)
  3. ****************
  4. .. only:: html
  5. .. contents::
  6. Introduction
  7. ============
  8. One problem that CMake users often face is sharing settings with other people
  9. for common ways to configure a project. This may be done to support CI builds,
  10. or for users who frequently use the same build. CMake supports two files,
  11. ``CMakePresets.json`` and ``CMakeUserPresets.json``, that allow users to
  12. specify common configure options and share them with others.
  13. ``CMakePresets.json`` and ``CMakeUserPresets.json`` live in the project's root
  14. directory. They both have exactly the same format, and both are optional
  15. (though at least one must be present if ``--preset`` is specified.)
  16. ``CMakePresets.json`` is meant to save project-wide builds, while
  17. ``CMakeUserPresets.json`` is meant for developers to save their own local
  18. builds. ``CMakePresets.json`` may be checked into a version control system, and
  19. ``CMakeUserPresets.json`` should NOT be checked in. For example, if a project
  20. is using Git, ``CMakePresets.json`` may be tracked, and
  21. ``CMakeUserPresets.json`` should be added to the ``.gitignore``.
  22. Format
  23. ======
  24. The files are a JSON document with an object as the root:
  25. .. literalinclude:: presets/example.json
  26. :language: json
  27. The root object recognizes the following fields:
  28. ``version``
  29. A required integer representing the version of the JSON schema. Currently,
  30. the only supported version is 1.
  31. ``cmakeMinimumRequired``
  32. An optional object representing the minimum version of CMake needed to
  33. build this project. This object consists of the following fields:
  34. ``major``
  35. An optional integer representing the major version.
  36. ``minor``
  37. An optional integer representing the minor version.
  38. ``patch``
  39. An optional integer representing the patch version.
  40. ``vendor``
  41. An optional map containing vendor-specific information. CMake does not
  42. interpret the contents of this field except to verify that it is a map if
  43. it does exist. However, the keys should be a vendor-specific domain name
  44. followed by a ``/``-separated path. For example, the Example IDE 1.0 could
  45. use ``example.com/ExampleIDE/1.0``. The value of each field can be anything
  46. desired by the vendor, though will typically be a map.
  47. ``configurePresets``
  48. An optional array of `Configure Preset`_ objects.
  49. ``buildPresets``
  50. An optional array of `Build Preset`_ objects.
  51. ``testPresets``
  52. An optional array of `Test Preset`_ objects.
  53. Configure Preset
  54. ^^^^^^^^^^^^^^^^
  55. Each entry of the ``configurePresets`` array is a JSON object
  56. that may contain the following fields:
  57. ``name``
  58. A required string representing the machine-friendly name of the preset.
  59. This identifier is used in the ``--preset`` argument. There must not be
  60. two presets in the union of ``CMakePresets.json`` and
  61. ``CMakeUserPresets.json`` in the same directory with the same name.
  62. ``hidden``
  63. An optional boolean specifying whether or not a preset should be hidden.
  64. If a preset is hidden, it cannot be used in the ``--preset=`` argument,
  65. will not show up in the :manual:`CMake GUI <cmake-gui(1)>`, and does not
  66. have to have a valid ``generator`` or ``binaryDir``, even from
  67. inheritance. ``hidden`` presets are intended to be used as a base for
  68. other presets to inherit via the ``inherits`` field.
  69. ``inherits``
  70. An optional array of strings representing the names of presets to inherit
  71. from. The preset will inherit all of the fields from the ``inherits``
  72. presets by default (except ``name``, ``hidden``, ``inherits``,
  73. ``description``, and ``displayName``), but can override them as
  74. desired. If multiple ``inherits`` presets provide conflicting values for
  75. the same field, the earlier preset in the ``inherits`` list will be
  76. preferred. Presets in ``CMakePresets.json`` may not inherit from presets
  77. in ``CMakeUserPresets.json``.
  78. This field can also be a string, which is equivalent to an array
  79. containing one string.
  80. ``vendor``
  81. An optional map containing vendor-specific information. CMake does not
  82. interpret the contents of this field except to verify that it is a map
  83. if it does exist. However, it should follow the same conventions as the
  84. root-level ``vendor`` field. If vendors use their own per-preset
  85. ``vendor`` field, they should implement inheritance in a sensible manner
  86. when appropriate.
  87. ``displayName``
  88. An optional string with a human-friendly name of the preset.
  89. ``description``
  90. An optional string with a human-friendly description of the preset.
  91. ``generator``
  92. An optional string representing the generator to use for the preset. If
  93. ``generator`` is not specified, it must be inherited from the
  94. ``inherits`` preset (unless this preset is ``hidden``).
  95. Note that for Visual Studio generators, unlike in the command line ``-G``
  96. argument, you cannot include the platform name in the generator name. Use
  97. the ``architecture`` field instead.
  98. ``architecture``, ``toolset``
  99. Optional fields representing the platform and toolset, respectively, for
  100. generators that support them. Each may be either a string or an object
  101. with the following fields:
  102. ``value``
  103. An optional string representing the value.
  104. ``strategy``
  105. An optional string telling CMake how to handle the ``architecture`` or
  106. ``toolset`` field. Valid values are:
  107. ``"set"``
  108. Set the respective value. This will result in an error for generators
  109. that do not support the respective field.
  110. ``"external"``
  111. Do not set the value, even if the generator supports it. This is
  112. useful if, for example, a preset uses the Ninja generator, and an IDE
  113. knows how to set up the Visual C++ environment from the
  114. ``architecture`` and ``toolset`` fields. In that case, CMake will
  115. ignore the field, but the IDE can use them to set up the environment
  116. before invoking CMake.
  117. ``binaryDir``
  118. An optional string representing the path to the output binary directory.
  119. This field supports `macro expansion`_. If a relative path is specified,
  120. it is calculated relative to the source directory. If ``binaryDir`` is not
  121. specified, it must be inherited from the ``inherits`` preset (unless this
  122. preset is ``hidden``).
  123. ``cmakeExecutable``
  124. An optional string representing the path to the CMake executable to use
  125. for this preset. This is reserved for use by IDEs, and is not used by
  126. CMake itself. IDEs that use this field should expand any macros in it.
  127. ``cacheVariables``
  128. An optional map of cache variables. The key is the variable name (which
  129. may not be an empty string), and the value is either ``null``, a boolean
  130. (which is equivalent to a value of ``"TRUE"`` or ``"FALSE"`` and a type
  131. of ``BOOL``), a string representing the value of the variable (which
  132. supports `macro expansion`_), or an object with the following fields:
  133. ``type``
  134. An optional string representing the type of the variable.
  135. ``value``
  136. A required string or boolean representing the value of the variable.
  137. A boolean is equivalent to ``"TRUE"`` or ``"FALSE"``. This field
  138. supports `macro expansion`_.
  139. Cache variables are inherited through the ``inherits`` field, and the
  140. preset's variables will be the union of its own ``cacheVariables`` and
  141. the ``cacheVariables`` from all its parents. If multiple presets in this
  142. union define the same variable, the standard rules of ``inherits`` are
  143. applied. Setting a variable to ``null`` causes it to not be set, even if
  144. a value was inherited from another preset.
  145. ``environment``
  146. An optional map of environment variables. The key is the variable name
  147. (which may not be an empty string), and the value is either ``null`` or
  148. a string representing the value of the variable. Each variable is set
  149. regardless of whether or not a value was given to it by the process's
  150. environment. This field supports `macro expansion`_, and environment
  151. variables in this map may reference each other, and may be listed in any
  152. order, as long as such references do not cause a cycle (for example,
  153. if ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  154. Environment variables are inherited through the ``inherits`` field, and
  155. the preset's environment will be the union of its own ``environment`` and
  156. the ``environment`` from all its parents. If multiple presets in this
  157. union define the same variable, the standard rules of ``inherits`` are
  158. applied. Setting a variable to ``null`` causes it to not be set, even if
  159. a value was inherited from another preset.
  160. ``warnings``
  161. An optional object specifying the warnings to enable. The object may
  162. contain the following fields:
  163. ``dev``
  164. An optional boolean. Equivalent to passing ``-Wdev`` or ``-Wno-dev``
  165. on the command line. This may not be set to ``false`` if ``errors.dev``
  166. is set to ``true``.
  167. ``deprecated``
  168. An optional boolean. Equivalent to passing ``-Wdeprecated`` or
  169. ``-Wno-deprecated`` on the command line. This may not be set to
  170. ``false`` if ``errors.deprecated`` is set to ``true``.
  171. ``uninitialized``
  172. An optional boolean. Setting this to ``true`` is equivalent to passing
  173. ``--warn-uninitialized`` on the command line.
  174. ``unusedCli``
  175. An optional boolean. Setting this to ``false`` is equivalent to passing
  176. ``--no-warn-unused-cli`` on the command line.
  177. ``systemVars``
  178. An optional boolean. Setting this to ``true`` is equivalent to passing
  179. ``--check-system-vars`` on the command line.
  180. ``errors``
  181. An optional object specifying the errors to enable. The object may
  182. contain the following fields:
  183. ``dev``
  184. An optional boolean. Equivalent to passing ``-Werror=dev`` or
  185. ``-Wno-error=dev`` on the command line. This may not be set to ``true``
  186. if ``warnings.dev`` is set to ``false``.
  187. ``deprecated``
  188. An optional boolean. Equivalent to passing ``-Werror=deprecated`` or
  189. ``-Wno-error=deprecated`` on the command line. This may not be set to
  190. ``true`` if ``warnings.deprecated`` is set to ``false``.
  191. ``debug``
  192. An optional object specifying debug options. The object may contain the
  193. following fields:
  194. ``output``
  195. An optional boolean. Setting this to ``true`` is equivalent to passing
  196. ``--debug-output`` on the command line.
  197. ``tryCompile``
  198. An optional boolean. Setting this to ``true`` is equivalent to passing
  199. ``--debug-trycompile`` on the command line.
  200. ``find``
  201. An optional boolean. Setting this to ``true`` is equivalent to passing
  202. ``--debug-find`` on the command line.
  203. Build Preset
  204. ^^^^^^^^^^^^
  205. Each entry of the ``buildPresets`` array is a JSON object
  206. that may contain the following fields:
  207. ``name``
  208. A required string representing the machine-friendly name of the preset.
  209. This identifier is used in the ``--preset`` argument. There must not be
  210. two presets (configure, build, or test) in the union of
  211. ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same
  212. directory with the same name.
  213. ``hidden``
  214. An optional boolean specifying whether or not a preset should be hidden.
  215. If a preset is hidden, it cannot be used in the ``--preset`` argument
  216. and does not have to have a valid ``configurePreset``, even from
  217. inheritance. ``hidden`` presets are intended to be used as a base for
  218. other presets to inherit via the ``inherits`` field.
  219. ``inherits``
  220. An optional array of strings representing the names of presets to
  221. inherit from. The preset will inherit all of the fields from the
  222. ``inherits`` presets by default (except ``name``, ``hidden``,
  223. ``inherits``, ``description``, and ``displayName``), but can override
  224. them as desired. If multiple ``inherits`` presets provide conflicting
  225. values for the same field, the earlier preset in the ``inherits`` list
  226. will be preferred. Presets in ``CMakePresets.json`` may not inherit from
  227. presets in ``CMakeUserPresets.json``.
  228. This field can also be a string, which is equivalent to an array
  229. containing one string.
  230. ``vendor``
  231. An optional map containing vendor-specific information. CMake does not
  232. interpret the contents of this field except to verify that it is a map
  233. if it does exist. However, it should follow the same conventions as the
  234. root-level ``vendor`` field. If vendors use their own per-preset
  235. ``vendor`` field, they should implement inheritance in a sensible manner
  236. when appropriate.
  237. ``displayName``
  238. An optional string with a human-friendly name of the preset.
  239. ``description``
  240. An optional string with a human-friendly description of the preset.
  241. ``environment``
  242. An optional map of environment variables. The key is the variable name
  243. (which may not be an empty string), and the value is either ``null`` or
  244. a string representing the value of the variable. Each variable is set
  245. regardless of whether or not a value was given to it by the process's
  246. environment. This field supports macro expansion, and environment
  247. variables in this map may reference each other, and may be listed in any
  248. order, as long as such references do not cause a cycle (for example, if
  249. ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  250. Environment variables are inherited through the ``inherits`` field, and
  251. the preset's environment will be the union of its own ``environment``
  252. and the ``environment`` from all its parents. If multiple presets in
  253. this union define the same variable, the standard rules of ``inherits``
  254. are applied. Setting a variable to ``null`` causes it to not be set,
  255. even if a value was inherited from another preset.
  256. ``configurePreset``
  257. An optional string specifying the name of a configure preset to
  258. associate with this build preset. If ``configurePreset`` is not
  259. specified, it must be inherited from the inherits preset (unless this
  260. preset is hidden). The build tree directory is inferred from the
  261. configure preset.
  262. ``inheritConfigureEnvironment``
  263. An optional boolean that defaults to true. If true, the environment
  264. variables from the associated configure preset are inherited after all
  265. inherited build preset environments, but before environment variables
  266. explicitly specified in this build preset.
  267. ``jobs``
  268. An optional integer. Equivalent to passing ``--parallel`` or ``-j`` on
  269. the command line.
  270. ``targets``
  271. An optional string or array of strings. Equivalent to passing
  272. ``--target`` or ``-t`` on the command line. Vendors may ignore the
  273. targets property or hide build presets that explicitly specify targets.
  274. This field supports macro expansion.
  275. ``configuration``
  276. An optional string. Equivalent to passing ``--config`` on the command
  277. line.
  278. ``cleanFirst``
  279. An optional bool. If true, equivalent to passing ``--clean-first`` on
  280. the command line.
  281. ``verbose``
  282. An optional bool. If true, equivalent to passing ``--verbose`` on the
  283. command line.
  284. ``nativeToolOptions``
  285. An optional array of strings. Equivalent to passing options after ``--``
  286. on the command line. The array values support macro expansion.
  287. Test Preset
  288. ^^^^^^^^^^^
  289. Each entry of the ``testPresets`` array is a JSON object
  290. that may contain the following fields:
  291. ``name``
  292. A required string representing the machine-friendly name of the preset.
  293. This identifier is used in the ``--preset`` argument. There must not be
  294. two presets (configure, build, or test) in the union of
  295. ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same
  296. directory with the same name.
  297. ``hidden``
  298. An optional boolean specifying whether or not a preset should be hidden.
  299. If a preset is hidden, it cannot be used in the ``--preset`` argument
  300. and does not have to have a valid ``configurePreset``, even from
  301. inheritance. ``hidden`` presets are intended to be used as a base for
  302. other presets to inherit via the ``inherits`` field.
  303. ``inherits``
  304. An optional array of strings representing the names of presets to
  305. inherit from. The preset will inherit all of the fields from the
  306. ``inherits`` presets by default (except ``name``, ``hidden``,
  307. ``inherits``, ``description``, and ``displayName``), but can override
  308. them as desired. If multiple ``inherits`` presets provide conflicting
  309. values for the same field, the earlier preset in the ``inherits`` list
  310. will be preferred. Presets in ``CMakePresets.json`` may not inherit from
  311. presets in ``CMakeUserPresets.json``.
  312. This field can also be a string, which is equivalent to an array
  313. containing one string.
  314. ``vendor``
  315. An optional map containing vendor-specific information. CMake does not
  316. interpret the contents of this field except to verify that it is a map
  317. if it does exist. However, it should follow the same conventions as the
  318. root-level ``vendor`` field. If vendors use their own per-preset
  319. ``vendor`` field, they should implement inheritance in a sensible manner
  320. when appropriate.
  321. ``displayName``
  322. An optional string with a human-friendly name of the preset.
  323. ``description``
  324. An optional string with a human-friendly description of the preset.
  325. ``environment``
  326. An optional map of environment variables. The key is the variable name
  327. (which may not be an empty string), and the value is either ``null`` or
  328. a string representing the value of the variable. Each variable is set
  329. regardless of whether or not a value was given to it by the process's
  330. environment. This field supports macro expansion, and environment
  331. variables in this map may reference each other, and may be listed in any
  332. order, as long as such references do not cause a cycle (for example, if
  333. ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
  334. Environment variables are inherited through the ``inherits`` field, and
  335. the preset's environment will be the union of its own ``environment``
  336. and the ``environment`` from all its parents. If multiple presets in
  337. this union define the same variable, the standard rules of ``inherits``
  338. are applied. Setting a variable to ``null`` causes it to not be set,
  339. even if a value was inherited from another preset.
  340. ``configurePreset``
  341. An optional string specifying the name of a configure preset to
  342. associate with this test preset. If ``configurePreset`` is not
  343. specified, it must be inherited from the inherits preset (unless this
  344. preset is hidden). The build tree directory is inferred from the
  345. configure preset.
  346. ``inheritConfigureEnvironment``
  347. An optional boolean that defaults to true. If true, the environment
  348. variables from the associated configure preset are inherited after all
  349. inherited test preset environments, but before environment variables
  350. explicitly specified in this test preset.
  351. ``configuration``
  352. An optional string. Equivalent to passing ``--build-config`` on the
  353. command line.
  354. ``overwriteConfigurationFile``
  355. An optional array of configuration options to overwrite options
  356. specified in the CTest configuration file. Equivalent to passing
  357. ``--overwrite`` for each value in the array. The array values
  358. support macro expansion.
  359. ``output``
  360. An optional object specifying output options. The object may contain the
  361. following fields.
  362. ``shortProgress``
  363. An optional bool. If true, equivalent to passing ``--progress`` on the
  364. command line.
  365. ``verbosity``
  366. An optional string specifying verbosity level. Must be one of the
  367. following:
  368. ``default``
  369. Equivalent to passing no verbosity flags on the command line.
  370. ``verbose``
  371. Equivalent to passing ``--verbose`` on the command line.
  372. ``extra``
  373. Equivalent to passing ``--extra-verbose`` on the command line.
  374. ``debug``
  375. An optional bool. If true, equivalent to passing ``--debug`` on the
  376. command line.
  377. ``outputOnFailure``
  378. An optional bool. If true, equivalent to passing
  379. ``--output-on-failure`` on the command line.
  380. ``quiet``
  381. An optional bool. If true, equivalent to passing ``--quiet`` on the
  382. command line.
  383. ``outputLogFile``
  384. An optional string specifying a path to a log file. Equivalent to
  385. passing ``--output-log`` on the command line. This field supports
  386. macro expansion.
  387. ``labelSummary``
  388. An optional bool. If false, equivalent to passing
  389. ``--no-label-summary`` on the command line.
  390. ``subprojectSummary``
  391. An optional bool. If false, equivalent to passing
  392. ``--no-subproject-summary`` on the command line.
  393. ``maxPassedTestOutputSize``
  394. An optional integer specifying the maximum output for passed tests in
  395. bytes. Equivalent to passing ``--test-output-size-passed`` on the
  396. command line.
  397. ``maxFailedTestOutputSize``
  398. An optional integer specifying the maximum output for failed tests in
  399. bytes. Equivalent to passing ``--test-output-size-failed`` on the
  400. command line.
  401. ``maxTestNameWidth``
  402. An optional integer specifying the maximum width of a test name to
  403. output. Equivalent to passing ``--max-width`` on the command line.
  404. ``filter``
  405. An optional object specifying how to filter the tests to run. The object
  406. may contain the following fields.
  407. ``include``
  408. An optional object specifying which tests to include. The object may
  409. contain the following fields.
  410. ``name``
  411. An optional string specifying a regex for test names. Equivalent to
  412. passing ``--tests-regex`` on the command line. This field supports
  413. macro expansion.
  414. ``label``
  415. An optional string specifying a regex for test labels. Equivalent to
  416. passing ``--label-regex`` on the command line. This field supports
  417. macro expansion.
  418. ``useUnion``
  419. An optional bool. Equivalent to passing ``--union`` on the command
  420. line.
  421. ``index``
  422. An optional object specifying tests to include by test index. The
  423. object may contain the following fields. Can also be an optional
  424. string specifying a file with the command line syntax for
  425. ``--tests-information``. If specified as a string, this field
  426. supports macro expansion.
  427. ``start``
  428. An optional integer specifying a test index to start testing at.
  429. ``end``
  430. An optional integer specifying a test index to stop testing at.
  431. ``stride``
  432. An optional integer specifying the increment.
  433. ``specificTests``
  434. An optional array of integers specifying specific test indices to
  435. run.
  436. ``exclude``
  437. An optional object specifying which tests to exclude. The object may
  438. contain the following fields.
  439. ``name``
  440. An optional string specifying a regex for test names. Equivalent to
  441. passing ``--exclude-regex`` on the command line. This field supports
  442. macro expansion.
  443. ``label``
  444. An optional string specifying a regex for test labels. Equivalent to
  445. passing ``--label-exclude`` on the command line. This field supports
  446. macro expansion.
  447. ``fixtures``
  448. An optional object specifying which fixtures to exclude from adding
  449. tests. The object may contain the following fields.
  450. ``any``
  451. An optional string specifying a regex for text fixtures to exclude
  452. from adding any tests. Equivalent to ``--fixture-exclude-any`` on
  453. the command line. This field supports macro expansion.
  454. ``setup``
  455. An optional string specifying a regex for text fixtures to exclude
  456. from adding setup tests. Equivalent to ``--fixture-exclude-setup``
  457. on the command line. This field supports macro expansion.
  458. ``cleanup``
  459. An optional string specifying a regex for text fixtures to exclude
  460. from adding cleanup tests. Equivalent to
  461. ``--fixture-exclude-cleanup`` on the command line. This field
  462. supports macro expansion.
  463. ``execution``
  464. An optional object specifying options for test execution. The object may
  465. contain the following fields.
  466. ``stopOnFailure``
  467. An optional bool. If true, equivalent to passing ``--stop-on-failure``
  468. on the command line.
  469. ``enableFailover``
  470. An optional bool. If true, equivalent to passing ``-F`` on the command
  471. line.
  472. ``jobs``
  473. An optional integer. Equivalent to passing ``--parallel`` on the
  474. command line.
  475. ``resourceSpecFile``
  476. An optional string. Equivalent to passing ``--resource-spec-file`` on
  477. the command line. This field supports macro expansion.
  478. ``testLoad``
  479. An optional integer. Equivalent to passing ``--test-load`` on the
  480. command line.
  481. ``showOnly``
  482. An optional string. Equivalent to passing ``--show-only`` on the
  483. command line. The string must be one of the following values:
  484. ``human``
  485. ``json-v1``
  486. ``rerunFailed``
  487. An optional bool. If true, equivalent to passing ``--rerun-failed`` on
  488. the command line.
  489. ``repeat``
  490. An optional object specifying how to repeat tests. Equivalent to
  491. passing ``--repeat`` on the command line. The object must have the
  492. following fields.
  493. ``mode``
  494. A required string. Must be one of the following values:
  495. ``until-fail``
  496. ``until-pass``
  497. ``after-timeout``
  498. ``count``
  499. A required integer.
  500. ``interactiveDebugging``
  501. An optional bool. If true, equivalent to passing
  502. ``--interactive-debug-mode 1`` on the command line. If false,
  503. equivalent to passing ``--interactive-debug-mode 0`` on the command
  504. line.
  505. ``scheduleRandom``
  506. An optional bool. If true, equivalent to passing ``--schedule-random``
  507. on the command line.
  508. ``timeout``
  509. An optional integer. Equivalent to passing ``--timeout`` on the
  510. command line.
  511. ``noTestsAction``
  512. An optional string specifying the behavior if no tests are found. Must
  513. be one of the following values:
  514. ``default``
  515. Equivalent to not passing any value on the command line.
  516. ``error``
  517. Equivalent to passing ``--no-tests=error`` on the command line.
  518. ``ignore``
  519. Equivalent to passing ``--no-tests=ignore`` on the command line.
  520. Macro Expansion
  521. ^^^^^^^^^^^^^^^
  522. As mentioned above, some fields support macro expansion. Macros are
  523. recognized in the form ``$<macro-namespace>{<macro-name>}``. All macros are
  524. evaluated in the context of the preset being used, even if the macro is in a
  525. field that was inherited from another preset. For example, if the ``Base``
  526. preset sets variable ``PRESET_NAME`` to ``${presetName}``, and the
  527. ``Derived`` preset inherits from ``Base``, ``PRESET_NAME`` will be set to
  528. ``Derived``.
  529. It is an error to not put a closing brace at the end of a macro name. For
  530. example, ``${sourceDir`` is invalid. A dollar sign (``$``) followed by
  531. anything other than a left curly brace (``{``) with a possible namespace is
  532. interpreted as a literal dollar sign.
  533. Recognized macros include:
  534. ``${sourceDir}``
  535. Path to the project source directory.
  536. ``${sourceParentDir}``
  537. Path to the project source directory's parent directory.
  538. ``${sourceDirName}``
  539. The last filename component of ``${sourceDir}``. For example, if
  540. ``${sourceDir}`` is ``/path/to/source``, this would be ``source``.
  541. ``${presetName}``
  542. Name specified in the preset's ``name`` field.
  543. ``${generator}``
  544. Generator specified in the preset's ``generator`` field. For build and
  545. test presets, this will evaluate to the generator specified by
  546. ``configurePreset``.
  547. ``${dollar}``
  548. A literal dollar sign (``$``).
  549. ``$env{<variable-name>}``
  550. Environment variable with name ``<variable-name>``. The variable name may
  551. not be an empty string. If the variable is defined in the ``environment``
  552. field, that value is used instead of the value from the parent environment.
  553. If the environment variable is not defined, this evaluates as an empty
  554. string.
  555. Note that while Windows environment variable names are case-insensitive,
  556. variable names within a preset are still case-sensitive. This may lead to
  557. unexpected results when using inconsistent casing. For best results, keep
  558. the casing of environment variable names consistent.
  559. ``$penv{<variable-name>}``
  560. Similar to ``$env{<variable-name>}``, except that the value only comes from
  561. the parent environment, and never from the ``environment`` field. This
  562. allows you to prepend or append values to existing environment variables.
  563. For example, setting ``PATH`` to ``/path/to/ninja/bin:$penv{PATH}`` will
  564. prepend ``/path/to/ninja/bin`` to the ``PATH`` environment variable. This
  565. is needed because ``$env{<variable-name>}`` does not allow circular
  566. references.
  567. ``$vendor{<macro-name>}``
  568. An extension point for vendors to insert their own macros. CMake will not
  569. be able to use presets which have a ``$vendor{<macro-name>}`` macro, and
  570. effectively ignores such presets. However, it will still be able to use
  571. other presets from the same file.
  572. CMake does not make any attempt to interpret ``$vendor{<macro-name>}``
  573. macros. However, to avoid name collisions, IDE vendors should prefix
  574. ``<macro-name>`` with a very short (preferably <= 4 characters) vendor
  575. identifier prefix, followed by a ``.``, followed by the macro name. For
  576. example, the Example IDE could have ``$vendor{xide.ideInstallDir}``.
  577. Schema
  578. ======
  579. :download:`This file </manual/presets/schema.json>` provides a machine-readable
  580. JSON schema for the ``CMakePresets.json`` format.