Commit Graph
38 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 0029686e86 presets: Extract configure dependency resolution 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
Richard 654a195d8b presets: Improve error diagnostics
Include the preset type when emitting generic error messages,
which avoids confusion over which preset is presenting problems
(e.g., if you you have a preset called "default" in each of the
configure, build, test, package and workflow preset types).

Include additional information about the specific error encountered
when processing a preset.

Fixes: #27774
2026-05-01 13:18:42 -04:00
Tyler Yankee 95edd93948 presets: Support loading from arbitrary file
Allow CMake, CTest, and CPack to read presets from a path given by
command-line argument instead of always requiring `CMakePresets.json`
or `CMakeUserPresets.json` in the source tree. This makes the presets
feature more extensible to cases in which the user doesn't have access
to the presets defined in the source tree (e.g., if the source tree is
not writable).

For now, there is no equivalent implementation of such an option in the
`cmake-gui`, nor for the recent presets functionality implemented in
`ctest_configure` and `ctest_build`.

Fixes: #27329
2026-04-30 08:04:26 -04:00
Tyler Yankee e75b62fd73 presets: Convert allowNoFiles to enum class
This improves readability at the call site when "yes" is desired.
2026-04-30 07:49:42 -04:00
Mickaël Germain e99fbf4100 Presets: Extract ResolvePreset utility for preset resolution
Replace duplicated inline preset lookup/validation logic in cmake.cxx,
cmCTest.cxx, and cpack.cxx with a shared ResolvePreset<T> template
method on cmCMakePresetsGraph.

Use the PresetType::kind() static method introduced in commit
0f3347bb27 (cmCMakePresetsGraph: generalize printing presets of
different types) to derive error message strings, replacing the
runtime presetType string parameter with a template parameter.

Error messages for configure presets now consistently include
"configure" in the preset type (e.g., "No such configure preset")
matching the pattern used by build, test, and package presets.
2026-04-22 15:40:13 -07:00
Brad King 111454d8e0 Merge topic 'cmake-diagnostics-state'
99318e49b9 Help: Mention when diagnostics were added
daec98ba61 Diagnostics: Fix passing diagnostic state to try_compile
e0b0ac4295 Diagnostics: Overhaul warnings in cmake-gui
ca5d569524 Diagnostics: Switch state to new system
618c074a8c Diagnostics: Use categories for presets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11855
2026-04-15 10:29:06 -04: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
Alex Turbov 0f3347bb27 cmCMakePresetsGraph: generalize printing presets of different types 2026-04-11 21:36:43 +04:00
Alex Turbov 9638624ebe cmCMakePresetsGraph: move the static PrintPresets out of class 2026-04-11 21:35:27 +04:00
Alex Turbov f60a1270bc cmCMakePresetsGraph: move static members to private scope 2026-04-11 21:28:27 +04:00
Alex Turbov 43a18bfaee cmCMakePresetsGraph: simplify presets printing
Remove public type `PrintPrecedingNewline` and its pointer passing
to every printing function.

It's enough to have a static flag variable inside the `printPrecedingNewline()`.
2026-04-11 20:57:17 +04:00
Alex Turbov 9aa7036093 cmCMakePresetsGraph: printPrecedingNewline() no need to be a member 2026-04-11 20:57:17 +04:00
Alex Turbov 661e8119dd cmCMakePresetsGraph: move GetGeneratorForPreset from header to *.cxx file 2026-04-11 20:57:16 +04:00
Alex Turbov 943749a1d3 cmCMakePresetsGraph: use struct for class w/o methods and only public data 2026-04-11 20:57:13 +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 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
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
Aliaksandr Averchanka 31c0e0de49 presets: Add graphviz support
Closes: #22164
2024-07-30 10:27:03 -04:00
Brad King 241ee252ce IWYU: Update for Debian 12 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 12.
2023-07-28 09:14:08 -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
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
Kyle Edwards 215b9148eb CMakePresets.json: Fix formatting of --list-presets=all
Only print an extra newline after a section if that section was
actually printed.
2022-08-31 10:13:32 -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
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
Kyle Edwards c18409cdac CMakePresets.json: Ensure configurePreset is reachable from current file 2022-02-02 15:17:30 -05:00
Brad King 63154cbf45 Merge topic 'vs-package-restore'
9aa7831f05 Presets: add resolve packages setting to build presets.
b2f8f0bb87 cmGlobalVisualStudio10Generator: Auto restore NuGet packages.
193b8fca52 cmBuildOptions: Split build arguments into separate object.
6a10103493 Help: Update preset schema description for version 3 entries.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6761
2022-01-24 11:46:29 -05:00
Carsten Rudolph 9aa7831f05 Presets: add resolve packages setting to build presets. 2022-01-22 06:35:41 -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 fd6ea2f67f Refactor: Rename cmCMakePresetsFile to cmCMakePresetsGraph
And change all references to "file" to say "graph" instead.
2022-01-06 18:52:30 -05:00