cmake-presets.7.rst 28 KB

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