cmake-presets.7.rst 33 KB

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