Commit Graph
35 Commits
Author SHA1 Message Date
Brad King b12192a593 Merge topic 'preset-template-helpers'
fffec0f86e presets: Extract common JSON field binds to helper
a1e4b92270 presets: Extract preset registration to helper
0029686e86 presets: Extract configure dependency resolution to helper

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12428
2026-08-25 11:32:27 -04:00
Tyler Yankee a1e4b92270 presets: Extract preset registration to helper 2026-08-23 07:25:05 -04:00
Maximilian Sander 2a9cde8b6e presets: Add defined listings with unavailable reasons
Add workflow and per-type defined values to cmake --list-presets.
Each -defined value lists every non-hidden preset of the selected type
and explains why unavailable presets cannot be used. The defined value
is an alias for configure-defined.

Support --list-presets=defined in cmake build and workflow modes,
ctest, and cpack. Propagate configure preset unavailability to
dependent build, test, package, and workflow presets.

Fixes: #28016, #26118
2026-08-19 16:47:50 +02:00
Matthew Woehlke 618c074a8c Diagnostics: Use categories for presets
Modify diagnostics to track which preset schema version corresponds to
the introduction of each diagnostic. Modify how we parse presets to use
the set of diagnostics to generate bindings, and to store diagnostics as
maps rather than as fixed members. Enforce that only diagnostics known
to the specified preset version are present.

This is a first and necessary step toward moving CMake's internals over
to flexible categories rather than each category having its own bespoke
variables and member functions.

Note that the presets documentation currently contains some broken
links, as it is anticipating further documentation updates that will
happen in a future commit.
2026-04-13 10:41:18 -04:00
Mickaël Germain 5278110386 CMakePresets: Add testPassthroughArguments to test presets
Add a testPassthroughArguments field to the execution object of test
presets, allowing users to forward arguments to test executables via
preset JSON. This extends the existing ctest -- CLI feature into the
preset system as schema version 12.

Preset arguments are assigned first, then CLI -- arguments are appended
after, so both sources combine naturally.

Fixes: #20470
2026-03-18 21:40:05 -07:00
Tyler Yankee 3c314349d5 presets: Evaluate fileDir macro ahead of schedule
Introduce a mechanism for "immediate" evaluation of preset macros as
they are defined in the current JSON file, rather than deferring until
after the preset graph is merged. This allows `${fileDir}` to always
be expanded with the path to the directory containing the file which
contains the macro, instead of the path being dependent on the preset
in which the macro is used (which could be defined and inherited from
elsewhere).

Bump to presets version 12 to provide backwards compatibility with the
old behavior.

Fixes: #26982
Relates: #27329, #27639
2026-03-17 08:16:50 -04:00
Tyler Yankee 23615b7ca4 presets: Allow jobs to match ctest -j with no value
Allow an empty string for the "jobs" field of test presets to mirror
the `ctest --parallel` option without a number specified, which
corresponds to setting the parallelism to the maximum of the number of
processors or 2.

Issue: #27070
2026-01-29 16:25:08 -05:00
Tyler Yankee 71ff5a9d6f presets: Disallow negative values for "jobs" fields
Jobs should never be negative, to mirror the behavior on the command
line for both `cmake --build` and `ctest`. This fixes unintended
behaviors where "-1" would lead to `cmake::NO_BUILD_PARALLEL_LEVEL`
being used for build presets and an integer overflow occurring for test
presets.

Bump to presets version 11 to signify the change.
2026-01-29 16:25:07 -05:00
Brad King 8832f78dd6 IWYU: Update for Debian 13 CI job
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library.  Update includes
to satisfy IWYU for our CI job under Debian 13.  Some patterns:

* Types named in virtual `override` signatures no longer require
  includes since the overridden signature already names them.

* A function argument's type needs to be included even if its constructor
  is called only by implicit conversion.  For example, constructing a
  `std::function` from a lambda now requires `<functional>`.

* Some prior mysterious `<type_traits>` inclusions are no longer required.
2025-11-12 14:54:35 -05:00
Kitware Robot 1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -05:00
Kitware Robot 0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Alex TurbovandMartin Duffy 0b334e5bfb cmJSONHelpers.h: Add generic predicate checking helper
And use it in the `cmCMakePresetsGraphReadJSON.cxx` to check
presets schema version in the declarative way.

Co-authored-by: Martin Duffy <martin.duffy@kitware.com>
2024-08-15 22:01:34 +04:00
Aliaksandr Averchanka 31c0e0de49 presets: Add graphviz support
Closes: #22164
2024-07-30 10:27:03 -04:00
Aliaksandr AverchankaandKanaiym 7d2cc6ece6 presets: Allow comments in presets files
Co-authored-by: Kanaiym <abdigak@clarkson.edu>
Fixes: #22791
2024-06-24 15:42:46 -04:00
Cristian Le 1a38ffc656 presets: Expand more macros in the include directive
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2024-02-21 13:47:08 -05:00
Cristian Le 741a207717 presets: Refactor macro expander implementation
Change the macro expander to use vtable dispatch.

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2024-02-16 07:50:01 -05:00
ChenMoFeiJin f1a7179520 presets: Add $schema property to JSON schema
Many modern code editors have support for JSON Schema.  When you specify
the `$schema` property in a JSON file, the editor can provide features
like auto-completion, error checking, etc., which can improve your
efficiency when writing and modifying the `CMakePresets.json` file.
2023-09-12 18:18:37 +08:00
Kyle Edwards 2588bf090c CMakePresets: Make error generators proper functions
And rename cmCMakePresetErrors to cmCMakePresetsErrors.
2023-08-16 09:47:29 -04:00
Zoran Angelov f552ba6e6d presets: add support for macro expansion to includes
Only `$penv{}` can be expanded when processing includes.
2023-04-26 10:03:53 -04:00
Artin Alavi 8e579b0228 presets: Add trace options to configure presets
Add JSON schema version 7 to support them.

Fixes: #22543
2023-03-30 09:18:53 -04:00
Martin Duffy 19305afd8a presets: Improve JSON parser and error messages 2023-03-29 10:41:19 -04:00
Rose 6d15754814 Make vector operations more efficient 2022-12-10 12:48:09 -05:00
Kyle Edwards 9270a02003 CMakePresets.json: Add outputJUnitFile to test presets schema 2022-10-18 15:41:29 -04:00
Kyle Edwards e316812884 CMakePresets.json: Add workflow presets to schema 2022-09-26 10:53:28 -04:00
Kyle Edwards b699610df4 cmCMakePresetsGraph: Add package presets 2022-08-31 10:18:01 -04:00
Sankhesh Jhaveri 47929ee98c presets: Add basic error forwarding from cmake preset json parser
Print errors only if there are errors.  Add filename for better
introspection, particularly for FileNotFound errors with presets.
2022-08-03 10:20:04 -04:00
Martin Duffy 30336dab66 cmJSONHelpers: Restructure cmJSONHelpers
Restructure cmJSONHelpers to prevent SunPro errors when passing context.
2022-05-05 12:12:12 -04:00
Frank Winklmeier 7a8ca8f842 cmCMakePresetsGraph: do not set default value for TestOutputTruncation
The `TestOutputTruncation` is an optional preset. Do not set a default
value to avoid failing the JSON schema version check.

Closes issue #23411.
2022-04-12 13:41:07 +02:00
Frank Winklmeier 140704d443 ctest: add option for output truncation
Add `--test-output-truncation` to `ctest`. This option can be used to
customize which part of the test output is being truncated. Currently
supported values are `tail`, `middle` and `head`.

Also add equivalent `CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` variable.

Fixes: #23206
2022-03-08 08:18:02 -05:00
Frank Winklmeier 359e5b17d8 presets: bump version to v5
Prepare for new test preset fields.
2022-03-08 08:18:02 -05:00
Kyle Edwards 0c2d234bc9 CMakePresets: Allow files included from CMakePresets.json to be anywhere
There are some valid use cases for allowing these files to be outside
the project directory. Relax the restriction, and include a strong
warning in the documentation.
2022-01-19 11:21:35 -05:00
Kyle Edwards 26a5512c0f CMakePresets: Add include field
Fixes: #21331
2022-01-06 19:46:41 -05:00
Kyle Edwards a239f23a98 Refactor: Generalize file graph in CMakePresets
Before this refactoring, presets had a simple flag that marked them
as "user" or "not user", and checking the file graph of two files
was as simple as checking this flag. This only allowed for two files
in the graph. Generalize the code to allow for arbitrarily many files
in the graph.
2022-01-06 19:46:41 -05:00
Kyle Edwards 84d440caac Refactor: Split JSON processing into configure, build, and test presets
Split up the file so that it won't be too big on some systems.
2022-01-06 18:52:30 -05:00
Kyle Edwards fd6ea2f67f Refactor: Rename cmCMakePresetsFile to cmCMakePresetsGraph
And change all references to "file" to say "graph" instead.
2022-01-06 18:52:30 -05:00