Use Levenshtein distance to track when the user may have made a typo in
an argument to `cmake -E` (i.e., an invalid mode; mode sub-arguments
are not tracked).
Use Levenshtein distance to track when the user may have made a typo in
an argument to `cmake`, `cmake --build`, `cmake --install`, or
`cmake --workflow`.
Amend commit 397fcd4663 (cmJSONState: Allow input stream as input,
2026-02-06) so that all constructors which feed into `ReadJSONStream`
bail on BOMs.
Add a test case for dynamic analysis tools.
Given that most call-sites throughout CMake now use the cmJSONState
wrapper instead of calling into jsoncpp directly, the fuzzing test
should also now go through the wrapper.
When CMake is linked against a sufficiently new jsoncpp supporting
exceptions, and built with the configuration to enable it, we can more
gracefully recover from runtime errors when parsing bad inputs.
In debug builds, we assert and abort to give more useful crashes for
development (i.e., instead of triggering UB). Otherwise, we get the
optimization benefits of `unreachable()` (or the older
platform-specific fallbacks per `cm/utility`).
Amends the documentation update in commit 24b76eaa93 (Help: Improve
readability and accuracy of runtime deps-related content, 2021-07-03,
v3.21.0-rc3~16^2).
Until a new feature is (potentially) implemented offering projects more
flexibility in this regard, the semantics around installation of
internal build-tree dependencies should be clarified, as it has caused
confusion on multiple occasions.
Issue: #28048
The copy button is convenient for copying code blocks from CMake's
documentation pages, and can be especially helpful when following the
CMake tutorial. It is implemented optionally so that developers without
the extension installed locally can still preview the site.
Fixes: #28046
The version installed from the system in our new Fedora 44 CI base
image has a beta version of ImageMagick installed, which the
FindImageMagick module can't parse.
The caller for `GetErrorMessage` _should_ only be calling this method
if there actual errors (i.e., `!errors.empty()`). However, in the
incidental absence of the intended usage, avoid `pop_back` on an empty
string.
These tests experience frequent timeouts in CI, which are either actual
timeouts due to low resource runners, or a platform-specific bug
causing an indefinite hang. Either way, it's beneficial to locate these
in their own test suite to reduce noise and ensure the rest of the
tests pass regularly.
These tests experience frequent timeouts in CI, which are either actual
timeouts due to low resource runners, or a platform-specific bug
causing an indefinite hang. Either way, it's beneficial to locate these
in their own test suite to reduce noise and ensure the rest of the
tests pass regularly.
File sets have evolved to be more ubiquitous throughout a CMake build,
outside the scope of simply the target_sources command. Move general
information to the `cmake-buildsystem(7)` manual and keep only
reference information specific to the syntax of target_sources in its
command page. Sprinkle some more cross-references to the new location.
Fixes: #27900
Suggested-By: Marc Chevrier <marc.chevrier@gmail.com>
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.
When finding BoringSSL, LibreSSL, or AWS-LC, version information may be
unavailable. Amend commit 54686cae64 (Utilities: Require OpenSSL >=
3.0.0 at configure time, 2026-06-26) by using the checks from upstream
curl to only error if we're using OpenSSL proper.
Fixes: #27978
As of commit ed48feeae8 (clang-cl: Add support for C++ modules,
2026-03-27, v4.4.0-rc1~428^2) CMake tries to support modules for
clang-cl, which can mostly be accomplished, except for the ClangCl VS
toolset, where the /scanDependencies flag is not yet supported.
Amend commit 3022f0363f (VS: set ScanSourceForModuleDependencies at
vcxproj level, 2024-04-27, v3.28.5~3^2) to only emit this setting when
scanning is supported by the toolchain.
Fixes: #27957
Issue: #27977
The discovery script created by commit 3748ca9f (GoogleTest: generate
single discovery script, 2026-04-08, v4.4.0-rc1~302^2~1) creates
generate-time collisions if gtest_discover_tests() is called on the
same target in the same directory with the same arguments multiple
times. Handle the case with a warning to preserve compatibility with
existing projects.
Fixes: #27940
Restore the logic from commit 6680df042e (GoogleTest: Avoid POST_BUILD
race condition for gtest_discover_tests(), 2025-10-26, v4.2.0-rc2~15^2)
that was lost in the refactoring in commit 3748ca9fc7 (GoogleTest:
generate single discovery script, 2026-04-08, v4.4.0-rc1~302^2~1). Add
a regression test.
Fixes: #27939, #27319, #27972
Incorporate the logic from commit 6680df042e (GoogleTest: Avoid
POST_BUILD race condition for gtest_discover_tests(), 2025-10-26,
v4.2.0-rc2~15^2) into the JSON test discovery mechanism introduced in
commit 1cdceae8e3 (GoogleTest: Parse discovered test list from JSON
output if supported, 2025-05-02, v4.2.0-rc1~533^2~2). Add a regression
test.
Fixes: #27939, #27319, #27972
Restore the ordering before the refactoring in commit 0f20ba5b68
(Ninja: Swift: Extract helpers and reorder module flags, 2026-04-10,
v4.4.0-rc1~273^2~1) to ensure the correct precedence with launchers.
Add regression tests.
Fixes: #27931, #27934
When the build is invoked under the native build tool's (commonly
spelled) `-C` option to change from the current working directory to a
given build tree, the default path to a snippet's `-ftime-trace` file
under its corresponding target's object directory was incorrectly
stored based on the path from the working directory.
Refactor CTest's logging to replace custom color code handling with the
infrastructure introduced in commit 329d755dbd (StdIo: Add a Terminal
abstraction to print color text, 2025-05-06).
Avoid ANSI escape sequences in files passed to `--output-log-file`.
Fixes: #27915
Backport the functionality from commit b5f555f687 (GoogleTest: Avoid
cluttering custom working directory during discovery, 2026-06-07,
v4.4.0-rc2~12^2). Work around the refactoring done in commit 3748ca9fc7
(GoogleTest: generate single discovery script, 2026-04-08,
v4.4.0-rc1~302^2~1).
The currently-vendored version of curl, when using OpenSSL, errors at
build time without at least version 3. Fail-fast at configure instead.
Fixes: #27902
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.
Extend (part of) commit f26e9fcbae (Help: Generate presets JSON schema,
documentation, 2026-04-08) to the `cmake-file-api(7)` page, for each of
the currently applicable object kinds (i.e., only those which have
undergone changes, which is predominantly the codemodel).
This standardization helps to improve both the readability and
maintainability of the document.
Conventionally, CMake help modes and manuals/documentation specify
placeholders for options which take one or many values after the option
name. Several existing `ctest` options do not follow this.
Fixes: #27827
The context is needed when running all exercises in this step.
Revise both this note and its mirror for `ctest` in Step 7 to
cross-reference the relevant flags.
Even though it doesn't necessarily reuse infrastructure, the other
cases in `RunCMake.CacheNewlines` are covering more similar code to
this case than those in `RunCMake.Configure`.
Reuse the logic from commit 637a0f7ed4 (cmCacheManager: Prevent
corruption from multiline help strings, 2025-02-04, v4.0.0-rc1~52^2)
for the warning message placed in the cache when a cache variable's
value contains one or more newline characters.
While we're at it, remove a superfluous early-exit in the help strings
method.
Fixes: #27807
Suggested-By: Yauheni Khnykin <yauheni.khnykin@here.com>
Cap the number of ELF sections, the section size, and the number of
dynamic entries to reasonable limits for real-world binaries to prevent
OOM on malformed inputs.
Previously, if a single source file was added to multiple file sets via
multiple `target_sources` calls, only the first call originally adding
it to the target was stored in the backtrace graph and referenced by
index in the singular "backtrace" field.
Add a "backtraces" field expanding this to cover all command
invocations which associate the given source file with that target.
Preserve the original "backtrace" field for compatibility. Update
spellings in the test suite to check against both fields.
Issue: #27035
The `fileSetIndex` field of target sources replies is incomplete, as a
single source file can be added to arbitrarily many file sets. Add a
`fileSetIndexes` field to report all file sets to which a source
belongs, and preserve `fileSetIndex` for compatibility as the index of
the most recent addition.
Tweak the test suite to use the plural spelling only in expected JSON
snippets and verify that the singular `fileSetIndex` is always the last
element of the new list. (Note that remaining occurrences of the
singular spelling correspond to "installers" objects, which is entirely
different.)
Fixes: #27035
Backport libarchive commit `16ad931073` (cpio reader: Validate pathname
in record_hardlink, 2026-05-08).
Add a fuzzing test case to expose this to dynamic analysis tools.
Build presets have a non-standard environment variable definition in
the schema yaml since they need extra Sphinx content. However, it was
missing the rule to disallow empty keys that the base environment
variable definition has.
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
References to `CMake[User]Presets.json` should correspond to behavior
pertaining to those files in particular, while references to presets
files generally should be disambiguated from that.
Re-spell "preset file" to "presets file" where applicable.
Make a few references to `cmake-presets(7)` more consistent.
Issue: #27329