cmake-presets.7.rst 29 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.. cmake-manual-description: CMakePresets.json

cmake-presets(7)
****************

.. only:: html

   .. contents::

Introduction
============

One problem that CMake users often face is sharing settings with other people
for common ways to configure a project. This may be done to support CI builds,
or for users who frequently use the same build. CMake supports two files,
``CMakePresets.json`` and ``CMakeUserPresets.json``, that allow users to
specify common configure options and share them with others.

``CMakePresets.json`` and ``CMakeUserPresets.json`` live in the project's root
directory. They both have exactly the same format, and both are optional
(though at least one must be present if ``--preset`` is specified.)
``CMakePresets.json`` is meant to save project-wide builds, while
``CMakeUserPresets.json`` is meant for developers to save their own local
builds. ``CMakePresets.json`` may be checked into a version control system, and
``CMakeUserPresets.json`` should NOT be checked in. For example, if a project
is using Git, ``CMakePresets.json`` may be tracked, and
``CMakeUserPresets.json`` should be added to the ``.gitignore``.

Format
======

32
The files are a JSON document with an object as the root:
33

34
35
.. literalinclude:: presets/example.json
  :language: json
36

37
The root object recognizes the following fields:
38

39
``version``
40

41
42
  A required integer representing the version of the JSON schema.
  The supported versions are ``1`` and ``2``.
43

44
``cmakeMinimumRequired``
45

46
47
  An optional object representing the minimum version of CMake needed to
  build this project. This object consists of the following fields:
48

49
  ``major``
50

51
    An optional integer representing the major version.
52

53
  ``minor``
54

55
    An optional integer representing the minor version.
56

57
  ``patch``
58

59
    An optional integer representing the patch version.
60

61
``vendor``
62

63
64
65
66
67
68
  An optional map containing vendor-specific information. CMake does not
  interpret the contents of this field except to verify that it is a map if
  it does exist. However, the keys should be a vendor-specific domain name
  followed by a ``/``-separated path. For example, the Example IDE 1.0 could
  use ``example.com/ExampleIDE/1.0``. The value of each field can be anything
  desired by the vendor, though will typically be a map.
69

70
``configurePresets``
71

72
  An optional array of `Configure Preset`_ objects.
73
  This is allowed in preset files specifying version 1 or above.
74

75
76
77
``buildPresets``

  An optional array of `Build Preset`_ objects.
78
  This is allowed in preset files specifying version 2 or above.
79
80
81
82

``testPresets``

  An optional array of `Test Preset`_ objects.
83
  This is allowed in preset files specifying version 2 or above.
84

85
86
87
88
89
Configure Preset
^^^^^^^^^^^^^^^^

Each entry of the ``configurePresets`` array is a JSON object
that may contain the following fields:
90

91
``name``
92

93
  A required string representing the machine-friendly name of the preset.
94
  This identifier is used in the :ref:`cmake --preset <CMake Options>` option.
95
96
97
  There must not be two configure presets in the union of ``CMakePresets.json``
  and ``CMakeUserPresets.json`` in the same directory with the same name.
  However, a configure preset may have the same name as a build or test preset.
98

99
``hidden``
100

101
102
103
104
105
106
  An optional boolean specifying whether or not a preset should be hidden.
  If a preset is hidden, it cannot be used in the ``--preset=`` argument,
  will not show up in the :manual:`CMake GUI <cmake-gui(1)>`, and does not
  have to have a valid ``generator`` or ``binaryDir``, even from
  inheritance. ``hidden`` presets are intended to be used as a base for
  other presets to inherit via the ``inherits`` field.
107

108
``inherits``
109

110
111
112
113
114
115
116
117
  An optional array of strings representing the names of presets to inherit
  from. The preset will inherit all of the fields from the ``inherits``
  presets by default (except ``name``, ``hidden``, ``inherits``,
  ``description``, and ``displayName``), but can override them as
  desired. If multiple ``inherits`` presets provide conflicting values for
  the same field, the earlier preset in the ``inherits`` list will be
  preferred. Presets in ``CMakePresets.json`` may not inherit from presets
  in ``CMakeUserPresets.json``.
118

119
120
  This field can also be a string, which is equivalent to an array
  containing one string.
121

122
``vendor``
123

124
125
126
127
128
129
  An optional map containing vendor-specific information. CMake does not
  interpret the contents of this field except to verify that it is a map
  if it does exist. However, it should follow the same conventions as the
  root-level ``vendor`` field. If vendors use their own per-preset
  ``vendor`` field, they should implement inheritance in a sensible manner
  when appropriate.
130

131
``displayName``
132

133
  An optional string with a human-friendly name of the preset.
134

135
``description``
136

137
  An optional string with a human-friendly description of the preset.
138

139
``generator``
140

141
142
143
  An optional string representing the generator to use for the preset. If
  ``generator`` is not specified, it must be inherited from the
  ``inherits`` preset (unless this preset is ``hidden``).
144

145
146
147
  Note that for Visual Studio generators, unlike in the command line ``-G``
  argument, you cannot include the platform name in the generator name. Use
  the ``architecture`` field instead.
148

149
``architecture``, ``toolset``
150

151
152
153
  Optional fields representing the platform and toolset, respectively, for
  generators that support them. Each may be either a string or an object
  with the following fields:
154

155
  ``value``
156

157
    An optional string representing the value.
158

159
  ``strategy``
160

161
162
    An optional string telling CMake how to handle the ``architecture`` or
    ``toolset`` field. Valid values are:
163

164
    ``"set"``
165

166
167
      Set the respective value. This will result in an error for generators
      that do not support the respective field.
168

169
    ``"external"``
170

171
172
173
174
175
176
      Do not set the value, even if the generator supports it. This is
      useful if, for example, a preset uses the Ninja generator, and an IDE
      knows how to set up the Visual C++ environment from the
      ``architecture`` and ``toolset`` fields. In that case, CMake will
      ignore the field, but the IDE can use them to set up the environment
      before invoking CMake.
177

178
``binaryDir``
179

180
181
182
183
184
  An optional string representing the path to the output binary directory.
  This field supports `macro expansion`_. If a relative path is specified,
  it is calculated relative to the source directory. If ``binaryDir`` is not
  specified, it must be inherited from the ``inherits`` preset (unless this
  preset is ``hidden``).
185

186
``cmakeExecutable``
187

188
189
190
  An optional string representing the path to the CMake executable to use
  for this preset. This is reserved for use by IDEs, and is not used by
  CMake itself. IDEs that use this field should expand any macros in it.
191

192
``cacheVariables``
193

194
195
196
197
198
  An optional map of cache variables. The key is the variable name (which
  may not be an empty string), and the value is either ``null``, a boolean
  (which is equivalent to a value of ``"TRUE"`` or ``"FALSE"`` and a type
  of ``BOOL``), a string representing the value of the variable (which
  supports `macro expansion`_), or an object with the following fields:
199

200
  ``type``
201

202
    An optional string representing the type of the variable.
203

204
  ``value``
205

206
207
208
    A required string or boolean representing the value of the variable.
    A boolean is equivalent to ``"TRUE"`` or ``"FALSE"``. This field
    supports `macro expansion`_.
209

210
211
212
213
214
215
  Cache variables are inherited through the ``inherits`` field, and the
  preset's variables will be the union of its own ``cacheVariables`` and
  the ``cacheVariables`` from all its parents. If multiple presets in this
  union define the same variable, the standard rules of ``inherits`` are
  applied. Setting a variable to ``null`` causes it to not be set, even if
  a value was inherited from another preset.
216

217
``environment``
218

219
220
221
222
223
224
225
226
  An optional map of environment variables. The key is the variable name
  (which may not be an empty string), and the value is either ``null`` or
  a string representing the value of the variable. Each variable is set
  regardless of whether or not a value was given to it by the process's
  environment. This field supports `macro expansion`_, and environment
  variables in this map may reference each other, and may be listed in any
  order, as long as such references do not cause a cycle (for example,
  if ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)
227

228
229
230
231
232
233
  Environment variables are inherited through the ``inherits`` field, and
  the preset's environment will be the union of its own ``environment`` and
  the ``environment`` from all its parents. If multiple presets in this
  union define the same variable, the standard rules of ``inherits`` are
  applied. Setting a variable to ``null`` causes it to not be set, even if
  a value was inherited from another preset.
234

235
``warnings``
236

237
238
  An optional object specifying the warnings to enable. The object may
  contain the following fields:
239

240
  ``dev``
241

242
243
244
    An optional boolean. Equivalent to passing ``-Wdev`` or ``-Wno-dev``
    on the command line. This may not be set to ``false`` if ``errors.dev``
    is set to ``true``.
245

246
  ``deprecated``
247

248
249
250
    An optional boolean. Equivalent to passing ``-Wdeprecated`` or
    ``-Wno-deprecated`` on the command line. This may not be set to
    ``false`` if ``errors.deprecated`` is set to ``true``.
251

252
  ``uninitialized``
253

254
255
    An optional boolean. Setting this to ``true`` is equivalent to passing
    ``--warn-uninitialized`` on the command line.
256

257
  ``unusedCli``
258

259
260
    An optional boolean. Setting this to ``false`` is equivalent to passing
    ``--no-warn-unused-cli`` on the command line.
261

262
  ``systemVars``
263

264
265
    An optional boolean. Setting this to ``true`` is equivalent to passing
    ``--check-system-vars`` on the command line.
266

267
``errors``
268

269
270
  An optional object specifying the errors to enable. The object may
  contain the following fields:
271

272
  ``dev``
273

274
275
276
    An optional boolean. Equivalent to passing ``-Werror=dev`` or
    ``-Wno-error=dev`` on the command line. This may not be set to ``true``
    if ``warnings.dev`` is set to ``false``.
277

278
  ``deprecated``
279

280
281
282
    An optional boolean. Equivalent to passing ``-Werror=deprecated`` or
    ``-Wno-error=deprecated`` on the command line. This may not be set to
    ``true`` if ``warnings.deprecated`` is set to ``false``.
283

284
``debug``
285

286
287
  An optional object specifying debug options. The object may contain the
  following fields:
288

289
  ``output``
290

291
292
    An optional boolean. Setting this to ``true`` is equivalent to passing
    ``--debug-output`` on the command line.
293

294
  ``tryCompile``
295

296
297
    An optional boolean. Setting this to ``true`` is equivalent to passing
    ``--debug-trycompile`` on the command line.
298

299
  ``find``
300

301
302
    An optional boolean. Setting this to ``true`` is equivalent to passing
    ``--debug-find`` on the command line.
303

304
305
306
307
308
309
310
311
312
Build Preset
^^^^^^^^^^^^

Each entry of the ``buildPresets`` array is a JSON object
that may contain the following fields:

``name``

  A required string representing the machine-friendly name of the preset.
313
314
  This identifier is used in the
  :ref:`cmake --build --preset <Build Tool Mode>` option.
315
316
317
  There must not be two build presets in the union of ``CMakePresets.json``
  and ``CMakeUserPresets.json`` in the same directory with the same name.
  However, a build preset may have the same name as a configure or test preset.
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380

``hidden``

  An optional boolean specifying whether or not a preset should be hidden.
  If a preset is hidden, it cannot be used in the ``--preset`` argument
  and does not have to have a valid ``configurePreset``, even from
  inheritance. ``hidden`` presets are intended to be used as a base for
  other presets to inherit via the ``inherits`` field.

``inherits``

  An optional array of strings representing the names of presets to
  inherit from. The preset will inherit all of the fields from the
  ``inherits`` presets by default (except ``name``, ``hidden``,
  ``inherits``, ``description``, and ``displayName``), but can override
  them as desired. If multiple ``inherits`` presets provide conflicting
  values for the same field, the earlier preset in the ``inherits`` list
  will be preferred. Presets in ``CMakePresets.json`` may not inherit from
  presets in ``CMakeUserPresets.json``.

  This field can also be a string, which is equivalent to an array
  containing one string.

``vendor``

  An optional map containing vendor-specific information. CMake does not
  interpret the contents of this field except to verify that it is a map
  if it does exist. However, it should follow the same conventions as the
  root-level ``vendor`` field. If vendors use their own per-preset
  ``vendor`` field, they should implement inheritance in a sensible manner
  when appropriate.

``displayName``

  An optional string with a human-friendly name of the preset.

``description``

  An optional string with a human-friendly description of the preset.

``environment``

  An optional map of environment variables. The key is the variable name
  (which may not be an empty string), and the value is either ``null`` or
  a string representing the value of the variable. Each variable is set
  regardless of whether or not a value was given to it by the process's
  environment. This field supports macro expansion, and environment
  variables in this map may reference each other, and may be listed in any
  order, as long as such references do not cause a cycle (for example, if
  ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)

  Environment variables are inherited through the ``inherits`` field, and
  the preset's environment will be the union of its own ``environment``
  and the ``environment`` from all its parents. If multiple presets in
  this union define the same variable, the standard rules of ``inherits``
  are applied. Setting a variable to ``null`` causes it to not be set,
  even if a value was inherited from another preset.

``configurePreset``

  An optional string specifying the name of a configure preset to
  associate with this build preset. If ``configurePreset`` is not
  specified, it must be inherited from the inherits preset (unless this
381
382
383
  preset is hidden). The build directory is inferred from the configure
  preset, so the build will take place in the same ``binaryDir`` that the
  configuration did.
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432

``inheritConfigureEnvironment``

  An optional boolean that defaults to true. If true, the environment
  variables from the associated configure preset are inherited after all
  inherited build preset environments, but before environment variables
  explicitly specified in this build preset.

``jobs``

  An optional integer. Equivalent to passing ``--parallel`` or ``-j`` on
  the command line.

``targets``

  An optional string or array of strings. Equivalent to passing
  ``--target`` or ``-t`` on the command line. Vendors may ignore the
  targets property or hide build presets that explicitly specify targets.
  This field supports macro expansion.

``configuration``

  An optional string. Equivalent to passing ``--config`` on the command
  line.

``cleanFirst``

  An optional bool. If true, equivalent to passing ``--clean-first`` on
  the command line.

``verbose``

  An optional bool. If true, equivalent to passing ``--verbose`` on the
  command line.

``nativeToolOptions``

  An optional array of strings. Equivalent to passing options after ``--``
  on the command line. The array values support macro expansion.

Test Preset
^^^^^^^^^^^

Each entry of the ``testPresets`` array is a JSON object
that may contain the following fields:

``name``

  A required string representing the machine-friendly name of the preset.
433
  This identifier is used in the :ref:`ctest --preset <CTest Options>` option.
434
435
436
  There must not be two test presets in the union of ``CMakePresets.json``
  and ``CMakeUserPresets.json`` in the same directory with the same name.
  However, a test preset may have the same name as a configure or build preset.
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499

``hidden``

  An optional boolean specifying whether or not a preset should be hidden.
  If a preset is hidden, it cannot be used in the ``--preset`` argument
  and does not have to have a valid ``configurePreset``, even from
  inheritance. ``hidden`` presets are intended to be used as a base for
  other presets to inherit via the ``inherits`` field.

``inherits``

  An optional array of strings representing the names of presets to
  inherit from. The preset will inherit all of the fields from the
  ``inherits`` presets by default (except ``name``, ``hidden``,
  ``inherits``, ``description``, and ``displayName``), but can override
  them as desired. If multiple ``inherits`` presets provide conflicting
  values for the same field, the earlier preset in the ``inherits`` list
  will be preferred. Presets in ``CMakePresets.json`` may not inherit from
  presets in ``CMakeUserPresets.json``.

  This field can also be a string, which is equivalent to an array
  containing one string.

``vendor``

  An optional map containing vendor-specific information. CMake does not
  interpret the contents of this field except to verify that it is a map
  if it does exist. However, it should follow the same conventions as the
  root-level ``vendor`` field. If vendors use their own per-preset
  ``vendor`` field, they should implement inheritance in a sensible manner
  when appropriate.

``displayName``

  An optional string with a human-friendly name of the preset.

``description``

  An optional string with a human-friendly description of the preset.

``environment``

  An optional map of environment variables. The key is the variable name
  (which may not be an empty string), and the value is either ``null`` or
  a string representing the value of the variable. Each variable is set
  regardless of whether or not a value was given to it by the process's
  environment. This field supports macro expansion, and environment
  variables in this map may reference each other, and may be listed in any
  order, as long as such references do not cause a cycle (for example, if
  ``ENV_1`` is ``$env{ENV_2}``, ``ENV_2`` may not be ``$env{ENV_1}``.)

  Environment variables are inherited through the ``inherits`` field, and
  the preset's environment will be the union of its own ``environment``
  and the ``environment`` from all its parents. If multiple presets in
  this union define the same variable, the standard rules of ``inherits``
  are applied. Setting a variable to ``null`` causes it to not be set,
  even if a value was inherited from another preset.

``configurePreset``

  An optional string specifying the name of a configure preset to
  associate with this test preset. If ``configurePreset`` is not
  specified, it must be inherited from the inherits preset (unless this
500
501
502
  preset is hidden). The build directory is inferred from the configure
  preset, so tests will run in the same ``binaryDir`` that the
  configuration did and build did.
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784

``inheritConfigureEnvironment``

  An optional boolean that defaults to true. If true, the environment
  variables from the associated configure preset are inherited after all
  inherited test preset environments, but before environment variables
  explicitly specified in this test preset.

``configuration``

  An optional string. Equivalent to passing ``--build-config`` on the
  command line.

``overwriteConfigurationFile``

  An optional array of configuration options to overwrite options
  specified in the CTest configuration file. Equivalent to passing
  ``--overwrite`` for each value in the array. The array values
  support macro expansion.

``output``

  An optional object specifying output options. The object may contain the
  following fields.

  ``shortProgress``

    An optional bool. If true, equivalent to passing ``--progress`` on the
    command line.

  ``verbosity``

    An optional string specifying verbosity level. Must be one of the
    following:

    ``default``

      Equivalent to passing no verbosity flags on the command line.

    ``verbose``

      Equivalent to passing ``--verbose`` on the command line.

    ``extra``

      Equivalent to passing ``--extra-verbose`` on the command line.

  ``debug``

    An optional bool. If true, equivalent to passing ``--debug`` on the
    command line.

  ``outputOnFailure``

    An optional bool. If true, equivalent to passing
    ``--output-on-failure`` on the command line.

  ``quiet``

    An optional bool. If true, equivalent to passing ``--quiet`` on the
    command line.

  ``outputLogFile``

    An optional string specifying a path to a log file. Equivalent to
    passing ``--output-log`` on the command line. This field supports
    macro expansion.

  ``labelSummary``

    An optional bool. If false, equivalent to passing
    ``--no-label-summary`` on the command line.

  ``subprojectSummary``

    An optional bool. If false, equivalent to passing
    ``--no-subproject-summary`` on the command line.

  ``maxPassedTestOutputSize``

    An optional integer specifying the maximum output for passed tests in
    bytes. Equivalent to passing ``--test-output-size-passed`` on the
    command line.

  ``maxFailedTestOutputSize``

    An optional integer specifying the maximum output for failed tests in
    bytes. Equivalent to passing ``--test-output-size-failed`` on the
    command line.

  ``maxTestNameWidth``

    An optional integer specifying the maximum width of a test name to
    output. Equivalent to passing ``--max-width`` on the command line.

``filter``

  An optional object specifying how to filter the tests to run. The object
  may contain the following fields.

  ``include``

    An optional object specifying which tests to include. The object may
    contain the following fields.

    ``name``

      An optional string specifying a regex for test names. Equivalent to
      passing ``--tests-regex`` on the command line. This field supports
      macro expansion.


    ``label``

      An optional string specifying a regex for test labels. Equivalent to
      passing ``--label-regex`` on the command line. This field supports
      macro expansion.

    ``useUnion``

      An optional bool. Equivalent to passing ``--union`` on the command
      line.

    ``index``

      An optional object specifying tests to include by test index. The
      object may contain the following fields. Can also be an optional
      string specifying a file with the command line syntax for
      ``--tests-information``. If specified as a string, this field
      supports macro expansion.

      ``start``

        An optional integer specifying a test index to start testing at.

      ``end``

        An optional integer specifying a test index to stop testing at.

      ``stride``

        An optional integer specifying the increment.

      ``specificTests``

        An optional array of integers specifying specific test indices to
        run.

  ``exclude``

    An optional object specifying which tests to exclude. The object may
    contain the following fields.

    ``name``

      An optional string specifying a regex for test names. Equivalent to
      passing ``--exclude-regex`` on the command line. This field supports
      macro expansion.

    ``label``

      An optional string specifying a regex for test labels. Equivalent to
      passing ``--label-exclude`` on the command line. This field supports
      macro expansion.

    ``fixtures``

      An optional object specifying which fixtures to exclude from adding
      tests. The object may contain the following fields.

      ``any``

        An optional string specifying a regex for text fixtures to exclude
        from adding any tests. Equivalent to ``--fixture-exclude-any`` on
        the command line. This field supports macro expansion.

      ``setup``

        An optional string specifying a regex for text fixtures to exclude
        from adding setup tests. Equivalent to ``--fixture-exclude-setup``
        on the command line. This field supports macro expansion.

      ``cleanup``

        An optional string specifying a regex for text fixtures to exclude
        from adding cleanup tests. Equivalent to
        ``--fixture-exclude-cleanup`` on the command line. This field
        supports macro expansion.

``execution``

  An optional object specifying options for test execution. The object may
  contain the following fields.

  ``stopOnFailure``

    An optional bool. If true, equivalent to passing ``--stop-on-failure``
    on the command line.

  ``enableFailover``

    An optional bool. If true, equivalent to passing ``-F`` on the command
    line.

  ``jobs``

    An optional integer. Equivalent to passing ``--parallel`` on the
    command line.

  ``resourceSpecFile``

    An optional string. Equivalent to passing ``--resource-spec-file`` on
    the command line. This field supports macro expansion.

  ``testLoad``

    An optional integer. Equivalent to passing ``--test-load`` on the
    command line.

  ``showOnly``

    An optional string. Equivalent to passing ``--show-only`` on the
    command line. The string must be one of the following values:

    ``human``

    ``json-v1``

  ``repeat``

    An optional object specifying how to repeat tests. Equivalent to
    passing ``--repeat`` on the command line. The object must have the
    following fields.

    ``mode``

      A required string. Must be one of the following values:

      ``until-fail``

      ``until-pass``

      ``after-timeout``

    ``count``

      A required integer.

  ``interactiveDebugging``

    An optional bool. If true, equivalent to passing
    ``--interactive-debug-mode 1`` on the command line. If false,
    equivalent to passing ``--interactive-debug-mode 0`` on the command
    line.

  ``scheduleRandom``

    An optional bool. If true, equivalent to passing ``--schedule-random``
    on the command line.

  ``timeout``

    An optional integer. Equivalent to passing ``--timeout`` on the
    command line.

  ``noTestsAction``

    An optional string specifying the behavior if no tests are found. Must
    be one of the following values:

    ``default``

      Equivalent to not passing any value on the command line.

    ``error``

      Equivalent to passing ``--no-tests=error`` on the command line.

    ``ignore``

      Equivalent to passing ``--no-tests=ignore`` on the command line.

785
786
787
Macro Expansion
^^^^^^^^^^^^^^^

788
789
790
791
792
793
794
As mentioned above, some fields support macro expansion. Macros are
recognized in the form ``$<macro-namespace>{<macro-name>}``. All macros are
evaluated in the context of the preset being used, even if the macro is in a
field that was inherited from another preset. For example, if the ``Base``
preset sets variable ``PRESET_NAME`` to ``${presetName}``, and the
``Derived`` preset inherits from ``Base``, ``PRESET_NAME`` will be set to
``Derived``.
795

796
797
798
799
It is an error to not put a closing brace at the end of a macro name. For
example, ``${sourceDir`` is invalid. A dollar sign (``$``) followed by
anything other than a left curly brace (``{``) with a possible namespace is
interpreted as a literal dollar sign.
800

801
Recognized macros include:
802

803
``${sourceDir}``
804

805
  Path to the project source directory.
806

807
``${sourceParentDir}``
808

809
  Path to the project source directory's parent directory.
810

811
``${sourceDirName}``
812

813
814
  The last filename component of ``${sourceDir}``. For example, if
  ``${sourceDir}`` is ``/path/to/source``, this would be ``source``.
815

816
``${presetName}``
817

818
  Name specified in the preset's ``name`` field.
819

820
``${generator}``
821

822
823
824
  Generator specified in the preset's ``generator`` field. For build and
  test presets, this will evaluate to the generator specified by
  ``configurePreset``.
825

826
``${dollar}``
827

828
  A literal dollar sign (``$``).
829

830
``$env{<variable-name>}``
831

832
833
834
835
836
  Environment variable with name ``<variable-name>``. The variable name may
  not be an empty string. If the variable is defined in the ``environment``
  field, that value is used instead of the value from the parent environment.
  If the environment variable is not defined, this evaluates as an empty
  string.
837

838
839
840
841
  Note that while Windows environment variable names are case-insensitive,
  variable names within a preset are still case-sensitive. This may lead to
  unexpected results when using inconsistent casing. For best results, keep
  the casing of environment variable names consistent.
842

843
``$penv{<variable-name>}``
844

845
846
847
848
849
850
851
  Similar to ``$env{<variable-name>}``, except that the value only comes from
  the parent environment, and never from the ``environment`` field. This
  allows you to prepend or append values to existing environment variables.
  For example, setting ``PATH`` to ``/path/to/ninja/bin:$penv{PATH}`` will
  prepend ``/path/to/ninja/bin`` to the ``PATH`` environment variable. This
  is needed because ``$env{<variable-name>}`` does not allow circular
  references.
852

853
``$vendor{<macro-name>}``
854

855
856
857
858
  An extension point for vendors to insert their own macros. CMake will not
  be able to use presets which have a ``$vendor{<macro-name>}`` macro, and
  effectively ignores such presets. However, it will still be able to use
  other presets from the same file.
859

860
861
862
863
864
  CMake does not make any attempt to interpret ``$vendor{<macro-name>}``
  macros. However, to avoid name collisions, IDE vendors should prefix
  ``<macro-name>`` with a very short (preferably <= 4 characters) vendor
  identifier prefix, followed by a ``.``, followed by the macro name. For
  example, the Example IDE could have ``$vendor{xide.ideInstallDir}``.
865
866
867
868
869
870

Schema
======

:download:`This file </manual/presets/schema.json>` provides a machine-readable
JSON schema for the ``CMakePresets.json`` format.