cmake-presets.7.rst 30 KB

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