cmake-presets.7.rst 36 KB

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