31 Commits
Author SHA1 Message Date
Maximilian Sander 02dd870535 presets: Add configurePresetName macro
Fixes: #28028
2026-08-25 14:33:10 -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
Maximilian Sander d4bb9f2c53 presets: Diagnose invalid test filter index types 2026-07-29 18:20:32 +02:00
Maximilian Sander 0779279585 presets: Identify unreachable configure references 2026-07-28 00:57:52 +02:00
Maximilian Sander 9f28db13e6 presets: Identify unknown configure preset references 2026-07-28 00:57:44 +02:00
Tyler Yankee 4eda69be82 Tests: Centralize JSON schema validation
As the number of areas in CMake for which we've provided JSON schemas
has expanded, testing infrastructure has mostly been copy-pasted across
the relevant test suites. Unify it to a single reusable validator
script and CMake helper.
2026-07-24 09:55:23 -04:00
Kyle Williams 6e89bd5d55 Presets: Forward presets-file to workflow steps
- Forward the '--presets-file <file>' arguments to each workflow step.
- Ensure tests do not auto-set CMakePresets.json
- Fix typos in test names

Fixes: 27932
2026-07-11 23:38:06 -05:00
Tyler Yankee 54be7af178 Tests: Remove empty CMakePresets *.cmake files
When adding a presets test case, the per-case `.cmake` files are
sometimes not necessary to exercise the test logic. Relax the inclusion
of such files and remove all empty placeholders.

Note that some non-empty `CMakePresets/Trace-*.cmake` files are also
removed; they only include other empty files, and nothing in the test
case assertions (trace outputs / stderr) exercises the include
statements themselves.
2026-06-01 16:31:58 -04: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
scivision d0100b4060 ctest: Avoid printing failed if nothing failed
Fixes: #27607
2026-04-14 15:56:49 -04:00
Brad King 284955b28e Merge topic 'preset-cmd-tests'
ef95ae2e45 cmake --workflow: Improve errors when no preset is specified
af78be98c5 cmake --build: Improve errors when no preset is specified
6014f09e97 cpack: Improve errors when no preset is specified
f8ae1bbbec ctest: Improve errors when no preset is specified

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11840
2026-03-20 08:56:19 -04:00
Tyler Yankee f8ae1bbbec ctest: Improve errors when no preset is specified
Apply the same logic to both "equals" and non-"equals" forms of the
argument when no preset is specified, and add test cases.
2026-03-19 10:18:22 -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 3f4e7fa3ac presets: Correct version-agnostic negative jobs
Amend commit 71ff5a9d6f (presets: Disallow negative values for "jobs"
fields, 2026-01-13) by adjusting the schema and tests to reflect that
this behavior change is agnostic to the version in the preset file.
2026-02-27 07:22:10 -05: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
Martin Duffy 19305afd8a presets: Improve JSON parser and error messages 2023-03-29 10:41:19 -04:00
Brad King e46a9d79fc Tests: Isolate more RunCMake cases from external ctest environment values
Fix a few RunCMake cases that were running `ctest` without isolating it
from external environment values that affect its behavior.

Fixes: #24153
2022-11-14 11:08:45 -05:00
Kyle Edwards bea4ed5430 CTest: Add support for outputJUnitFile in presets
Fixes: #22400
2022-10-18 16:52:23 -04:00
Kyle Edwards 757786bb73 Tests: Add test for outputLogFile in CMakePresets.json 2022-10-18 15:20:44 -04:00
Kyle Edwards b68c3596e7 CMakePresets.json: Disallow extra properties in test output schema
And add test for testOutputTruncation being unsupported.
2022-10-18 14:40:11 -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
Frank Winklmeier 359e5b17d8 presets: bump version to v5
Prepare for new test preset fields.
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
Kyle Edwards 8bc5c8961e CMakePresets.json: Add the ability to conditionally disable presets 2021-03-22 15:04:54 -04:00
Sam Freed b9eb3541cf Tests: update tests to catch invalid configurePreset at read-time 2021-03-15 14:53:00 -07:00
Brad King e95f7aa0ed Merge topic 'preset-flag-consistency' into release-3.20
6fa3647023 ctest: Add support for '--prefix=<prefix>' form of the argument
3357d37761 cmake: Add support for '--build --prefix=<prefix>' form of the argument
2f13fdef0a cmake: Document '--preset <preset>' form of the argument

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5849
2021-02-24 09:46:52 -05:00
Kyle Edwards afaa69f5b3 Tests: Remove comments from CMakePresetsTest/Good.json.in 2021-02-24 09:33:50 -05:00
Brad King 6fa3647023 ctest: Add support for '--prefix=<prefix>' form of the argument
The main `cmake --preset` argument for configure presets supports both
forms, so support it for `ctest --preset` too.

Fixes: #21855
2021-02-23 09:22:00 -05:00
Sam Freed b500935b94 Tests: Add test preset tests 2021-02-04 11:39:52 -05:00