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
Backport libarchive commit `1f5454575f` (cab reader: Fix use of
uninitialized values from Huffman, 2026-04-23).
Add a fuzzing test case to expose this to dynamic analysis tools.
Use `cmake -E create_symlink` or `file(CREATE_LINK)` as appropriate
instead of `ln -sf` on UNIX only to extend cases of (a) symlinks inside
archives and (b) archive extraction to a directory symlink to non-UNIX
platforms where either of these modes may be supported.
The latter relies on the NEW behavior of CMP0205 as it uses
`COPY_ON_ERROR` for platforms where directory symlinks aren't
supported.
Issue: #27756
When removing the destination directory link when it already exists
before making the new link, only the (destination) link should be
removed, not the (source) directory itself. When COPY_ON_ERROR is
specified and the destination is a directory, only then should CMake
remove it, since it could likely be placing a new directory there in
its place.
With this new behavior, adjust the conditions for the symlink test from
commit a73ddd2ddb (file(CREATE_LINK): Implement COPY_ON_ERROR for
directories, 2025-10-15, v4.3.0-rc1~599^2). The newly modified test
case should be run on systems that do and don't support directory
symlinks, with slightly different outcomes that are verified.
Fixes: #27747
Ensure we only warn when COPY_ON_ERROR is specified. While we're at it,
tweak the spelling and apply consistent policy & logic ordering in
compound conditions.
Commit 03f19aa4ea (cmSystemTools: Fix path traversal vulnerability in
archive extraction, 2026-01-06, v4.3.0-rc1~179^2) incidentally
introduced the `ARCHIVE_EXTRACT_SECURE_SYMLINKS` flag when extracting
archives, which prevents extraction of objects whose location would be
altered by a symlink on disk. However, this particular behavior change
was never documented or tested alongside the other changes in the
commit (absolute paths and path traversal components).
Divergent behavior of this flag from `libarchive` on Windows and
non-Windows platforms needs further investigation. In particular, on
Windows, archives cannot be extracted through directory symlinks, but
can be extracted through junctions. On Linux, archives *can* still be
extracted through symlinks, and archives containing symlinks can be
extracted as well.
The symlink change breaks compatibility with many common use cases of
existing projects, e.g., when extracting an archive inside a symlinked
build directory. Revert the flag until this issue can be explored in a
future version of CMake.
Fixes: #27752
Reported-by: scivision <scivision@users.noreply.github.com>
"Compression format unsupported" errors of this form can only possibly
come from `file(ARCHIVE_CREATE)`, so we don't need to track the line
number of the called function. Reduce the need to update these numbers
every time the test helper script is updated.
Also, correct the documentation added in commit 98f9874703 (cmake:
Add per-language link flags for all target types, 2025-12-17) by
placing the variables in the proper section of cmake-variables(7).
Issue: #21934
Testing with both C and C++ is not currently required to support any
functionality in the test cases, so remove the C++ toolchain detection
which, when repeated for each test case, makes it run substantially
faster.
Consolidate the description of precedence during evaluation. Use xrefs
to improve syntax highlighting. Remove an outdated `versionadded`
directive for CMake 2.6.
Two targets whose names differ only in a `.exe` suffix create a
conflict when adding target- and file-level dependencies for a custom
command. Add CMP0212 to provide compatibility with the old behavior.
Issue: #27612
Commit 79c88703eb (instrumentation: Add JSON schema for query files,
2026-01-14, v4.3.0-rc1~109^2) added the schema file, but pointed to a
`$schema` which doesn't exist.
Issue: #27504
Improve argument parsing in the hook script. Ensure consistency between
test cases by always configuring query files with their callback
defined by logic in the test case.
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
Prepare for future changes where the full preset graph will not yet be
merged while expanding macros, and the version will be taken from the
standalone file instead of the origin of the graph.
Since commit 95dc40d8a8 (Experimental: Remove Instrumentation
experimental gating, 2026-02-03), using the instrumentation feature
without the experimental UUID requires CMake 4.3.
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.
See commit 23615b7ca4 (presets: Allow jobs to match `ctest -j` with no
value, 2025-12-15) and commit 71ff5a9d6f (presets: Disallow negative
values for "jobs" fields, 2026-01-13) for the changes.
Also update `cmake-presets(7)` itself to correct the behavior change
from the prior commit not respecting the presets file version.
Add explicit cross-references for commands which optionally take an
output variable (otherwise modifying their input in-place) for clarity.
Note that `cmake_path` should not be used to modify variables reserved
by CMake.
Improve references to the "CMake-style" semicolon-separated lists, and
apply those corresponding changes to the `file` command page.
The conversion between internal list representations led to empty
directories being left behind when processing generator expressions in
the destination. This ensures the intended behavior of creating a
destination directory but installing nothing into it when no <dirs> are
specified, regardless of the presence or absence of genex.
Further, an explicit empty string <dir> (via `""`, or an undefined
variable) led to the current source directory being expanded as a file
to install, leading to the generation of an infinitely recursive
install command. Disallow this behavior, forcing projects to explicitly
specify the current source directory if that is their intention.
Fixes: #27568