cmake-presets.7.rst 29 KB

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