cmake-presets.7.rst 29 KB

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