Commit Graph
7502 Commits
Author SHA1 Message Date
Tyler Yankee b63bcda722 CUDA, HIP: Revert false support for LINKER_LAUNCHER
The implementation in commits 77312cc6 (CUDA: Add support for
[CMAKE_]CUDA_LINKER_LAUNCHER, 2025-05-30, v4.1.0-rc1~80^2~1) and
cdf2a36f (HIP: Add support for [CMAKE_]HIP_LINKER_LAUNCHER, 2025-05-30,
v4.1.0-rc1~80^2) is broken, and the tests are wrongly configured
so as to never actually run. Revert the entire feature to avoid future
confusion, including documented support.

Enable the test for Fortran, which was added but untested by commit
d176a8c5ce (Fortran: Add support for [CMAKE_]Fortran_LINKER_LAUNCHER,
2025-05-26, v4.1.0-rc1~96^2), and whose implementation works.

Issue: #26967
2026-09-17 18:07:42 -04:00
Matthew Woehlke 23f1cb47c7 cmTarget: Don't crash on empty IMPORTED_CONFIGURATIONS
The logic to select an imported configuration handled the case when
`IMPORTED_CONFIGURATIONS` was missing, but assumed that if it was
present, it was non-empty, which could cause CMake to crash if that
happens. (To be fair, I believe this would never happen for imports
generated by CMake.) Adjust the logic slightly to follow the same code
path when `IMPORTED_CONFIGURATIONS` is empty as is taken if it's
missing.

Fixes: #28065
2026-09-02 13:36:50 -04:00
Daniel Pfeifer 5e5467bfc3 GoogleTest: Revert "Base on builtin command discover_tests"
Revert commit a324c2bb58 (GoogleTest: Base on builtin command
discover_tests, 2026-03-01, v4.4.0-rc1~30^2).  The `discover_tests`
implementation does not persist already-discovered tests across ctest
runs, making it much slower on projects whose test binaries take a while
just to start up and list tests.  Revert to the prior implementation
pending caching support in `discover_tests`.

Fixes: #28053
Issue: #28060
2026-08-28 11:08:59 -04:00
Brad King 1eb64f8624 Merge topic 'autogen-vs-reduce-target-count' into release-4.4
d963b87ab4 Autogen: Reduce the number of targets under Visual Studio
2b5ad7e395 Autogen: Register per-config timestamp file with its full path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12409
2026-08-24 12:31:25 -04:00
Joerg Bornemann d963b87ab4 Autogen: Reduce the number of targets under Visual Studio
Commit 680fbb112a (Autogen: Enable depfile support for Visual Studio and
Xcode generators) disabled the PRE_BUILD optimization when a depfile is
used, because a PRE_BUILD event cannot carry depfile dependencies. Since
then, every target with AUTOMOC or AUTOUIC enabled gains an
'<ORIGIN>_autogen' and an '<ORIGIN>_autogen_timestamp_deps' target,
which the Visual Studio generators turn into two extra projects per
target in the generated solution.

Attach the autogen custom command to the origin target instead. The
custom command still carries the depfile, and the dependencies of the
origin target provide the ordering that
'<ORIGIN>_autogen_timestamp_deps' provides otherwise, because MSBuild
builds all referenced projects before any step of the referencing
project.

Use the conditions of the PRE_BUILD event, so that the
'<ORIGIN>_autogen' target keeps existing wherever it existed before
depfiles were enabled for the Visual Studio generators. In particular,
projects that name the target in add_dependencies() keep working.

Ninja and the Makefile generators keep the separate targets. Extra
targets have no cost for them, and '<ORIGIN>_autogen' has always existed
there.

The Xcode generator gained the same two targets per origin target in
4.4, but attaching the custom command there needs some more thoughts on
the per-config timestamp file first: Xcode rejects targets whose sources
vary by configuration, and with AUTOGEN_BETTER_GRAPH_MULTI_CONFIG the
timestamp file is per configuration.

Fixes: #28034
Fixes: #28033
2026-08-14 13:14:54 +02:00
Evan Wilde e4a37fbf15 Tests/RunCMake/Swift: Add CMP0195 behavior checks
Adding checks to ensure that CMP0195 has the desired effect. If the
Swift compiler is too old and does not include the module triple in the
emitted target info, we won't set `CMAKE_Swift_MODULE_TRIPLE` and end up
with the flat directory structure. In this case, these tests won't have
the expected layout.

Issue: #28021
2026-08-13 10:18:16 -04:00
Evan Wilde b7a78568c3 CMP0215: Update NEW behavior to require CMP0157/CMP0195 to be NEW
Update CMP0215 to avoid attempting to iterate through the flags
looking for `-emit-module-path` ins the user-specified flags. We don't
do this anywhere else in the code. The existing implementation didn't
handle correctly parsing the flag so `-I blah/my-emit-module-path/` and
`-Xcc -emit-module-path ...` would both trigger it, result in the
compiler not emitting any module. Furthermore, it didn't include the
user-specified module path as part of the build graph resulting in an
incorrect build graph that would never resolve.

The only two appropriate layouts for the module are either the flat
binary module file with the name `<module-name>.swiftmodule`, or the
nested form with
`<module-name>.swiftmodule/<module-triple>.swiftmodule`. The noted
Swift-Syntax situation passes the explicit `-emit-module-path` to get to
the latter form. This form is automatically emitted by CMake when
CMP0195 is `NEW`, removing the need for the flag. The Swift project
generally recommends the nested directory structure since it gathers all
of the generated interface outputs from the compiler (textual swift
interfaces, swiftdoc, sourceinfo, and the binary swiftmodule file) in a
single place, and since it uses the module triple in the filename,
cleanly allows fat mach-o binaries on Apple platforms.

Fixes: #28021
2026-08-13 10:14:16 -04:00
Brad King 478912138b Merge topic 'list-transform-shared-state' into release-4.4
3151f7824f cmList: Fix shared state across nested list(TRANSFORM) calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12390
2026-08-12 11:42:40 -04:00
Mickaël Germain 3151f7824f cmList: Fix shared state across nested list(TRANSFORM) calls
The TRANSFORM action registry held one live action instance per action for
the whole process, and each instance carried per-call state: a raw Selector
pointer, REPLACE's helper, APPEND/PREPEND's operands.  That was harmless
while every action ran to completion uninterrupted, but commit c7af6e94d8
(list(TRANSFORM): Add PREDICATE selector, 2026-04-08, v4.4.0-rc1) added a
selector that runs a user function once per element, interleaved with the
transform.  User code reentering list(TRANSFORM) with the same action now
rebinds the shared instance mid-flight.  That produces silently wrong
results, and a use-after-free once any element is transformed after the
reentering one.  It needs no unusual code to hit: a predicate calling
find_package(Python) reaches list(TRANSFORM ... REPLACE) inside FindPython's
own module.

Make action objects immutable and per-call.  Operands and the selector become
constructor arguments, Initialize is deleted, and the registry becomes a
constexpr table of metadata with a MakeTransformAction factory.  The
InSelection guard, duplicated in all eight actions, moves into the base class.

This also closes a second hole in the same machinery.  TransformActionApply
overrode only the vector form of Initialize, so transform(APPLY, "f",
selector) dispatched to the empty two-argument virtual in the base, left
Selector null, and dereferenced it.  With no virtual Initialize left to
inherit, an APPLY action without a cmMakefile is no longer constructible, so
the throwing stub that guarded the vector form is no longer needed.

Close a third, from commit 651f82642c (Add APPLY action for list(TRANSFORM),
2026-04-08, v4.4.0-rc1): the cmMakefile overload performs APPLY
unconditionally but validated only the arity of the action passed to it.
APPEND, PREPEND and APPLY all take one argument, so transform(APPEND, "x",
makefile) passed validation and then silently ran APPLY, calling "x" as a
function instead of appending it.  Reject any action but APPLY up front.
That path is unreachable from CMake code, since HandleTransformCommand only
selects the overload for APPLY, and Tests/CMakeLib has no cmMakefile to drive
it with, so it carries no test.

Document the predicate's evaluation order while here.  It runs once per
element, immediately before that element would be transformed.  The manual
did not state the timing, which matters precisely because a predicate that
reenters list(TRANSFORM) observes the outer call mid-flight.

Fixes: #28031
2026-08-11 11:36:08 -04:00
Matthew Woehlke 3209535fb3 Check*: Restore toleration of false-like requirements
Commit 7644d557df (Check*: Refactor variable handling, 2026-07-20,
v4.4.1~12^2~1) introduced a subtle regression in the handling of
`CMAKE_REQUIRED_LINK_OPTIONS` and `CMAKE_REQUIRED_LIBRARIES` which
resulted in an error if these were set to a 'false-like' value. This
could happen, for example, if the user passes `<name>_LIBS`, which
happens to have the value `<name>-NOTFOUND`. Previously, such values
would be ignored.

Fix it by separately checking for user- or module-provided link options
or link libraries. (We were already doing this for the other variables
used to propagate requirements into checks.)

Fixes: #28026
2026-08-07 14:14:52 -04:00
Brad King 7ecf782279 Merge topic 'file-GLOB-CONFIGURE_DEPENDS-quoting' into release-4.4
249e364dd7 Merge branch 'backport-3.31-file-GLOB-CONFIGURE_DEPENDS-quoting'
2c89c2a74c file(GLOB): Teach CONFIGURE_DEPENDS to handle quotes in matched file names
9a9ce6637b file(GLOB): Teach CONFIGURE_DEPENDS to handle quotes in matched file names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12378
2026-08-07 10:53:31 -04:00
Brad King 2c89c2a74c file(GLOB): Teach CONFIGURE_DEPENDS to handle quotes in matched file names
Otherwise a malicious file name can inject code into the verification
script.

Fixes: #28023
2026-08-06 10:38:49 -04:00
Brad King 89e6a0c18d Tests: Add case covering GoogleTest odd PROPERTIES warning
Follow up commit 1b2f3287f7 (GoogleTest: Restore toleration
of odd test PROPERTIES count, 2026-07-30, v4.4.2~1^2).

Issue: #28004
2026-07-31 10:23:33 -04:00
Daniel Pfeifer 6147180017 discover_tests: Require properties to be key-value pairs
Issue: #28004
2026-07-30 12:21:23 -04:00
Brad King 33a9ce0cd9 Merge topic 'tests-instrumentation-split-make' into release-4.4
cfede7be9d Tests/Instrumentation: Split make cases out to separate suite

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12337
2026-07-30 11:54:19 -04:00
Brad King c01169db6e Merge topic 'test-check-required-flags' into release-4.4
fd6f2555d4 Tests: Cover CMAKE_REQUIRED_FLAGS in Check* modules

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12346
2026-07-30 11:30:56 -04:00
Josef Šimánek fd6f2555d4 Tests: Cover CMAKE_REQUIRED_FLAGS in Check* modules
Commit a72e241200 (Check*: Restore more toleration of `;-W...` in
CMAKE_REQUIRED_FLAGS, 2026-07-21) updated the Check* modules to share
required-flag handling without adding coverage for those paths.
Exercise each probe with required definitions followed by a warning
option.

Without the compatibility handling, CMake rejects the warning option.
Without the required definitions, all seven checks fail to find their
header, functions, prototype, or type.

Issue: #28001
2026-07-29 17:27:21 -04:00
Tyler Yankee cfede7be9d Tests/Instrumentation: Split make cases out to separate suite
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.
2026-07-29 10:59:42 -04:00
Tyler Yankee f880286604 Tests/NinjaMultiConfig: Split into three variants
These experience timeouts in CI. Split into three equally-ish sized
buckets so each can run independently.
2026-07-29 10:51:04 -04:00
Matthew Woehlke f9d99e3892 Tests: Fix symbolic component tests
The tests added in commit d92b6c3e20 (CPS: Add Symbolic Components,
2025-09-01, v4.2.0-rc1~48^2~1) had an inverted conditional, such that
they passed if the output did NOT match what was expected. The expected
expressions were also improperly escaped, which "canceled" this error,
allowing the tests to erroneously pass. Fix both of these errors.
2026-07-27 11:53:05 -04:00
Brad King 23f412a704 Merge topic 'fix-mod-manifest-nested-dirs' into release-4.4
539b097bd8 CPS/c++modules: Use file system root as base directory for module manifests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12326
2026-07-27 10:03:41 -04:00
Vito Gamberini 539b097bd8 CPS/c++modules: Use file system root as base directory for module manifests
Fixes: #27989
2026-07-26 16:34:33 -04:00
Vito Gamberini c7ffbc3a26 CPS: Add package requirements for per-config link dependencies
Fixes: #27987
2026-07-25 16:09:57 -04:00
Brad King 423d5e4ff6 Merge topic 'fix-synth-preproc-cxx-options' into release-4.4
6fb8e308df c++modules: Account for preprocessor flags in compile options

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12310
2026-07-24 08:16:35 -04:00
Vito Gamberini 6fb8e308df c++modules: Account for preprocessor flags in compile options
Fixes: #27973
2026-07-23 09:19:13 -04:00
Brad King 84f6f4aa64 Merge topic 'fix-diagnostic-action-order' into release-4.4
0d36692275 Diagnostics: Fix interaction with cached state

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12312
2026-07-23 08:29:42 -04:00
Matthew Woehlke 0d36692275 Diagnostics: Fix interaction with cached state
The prior mechanism for reconciling cached diagnostic state with updates
from presets / command-line arguments based on whether the latter
modified diagnostics from their default state did not work. This is
because alterations that would not change the state relative to the
default were not recorded, even if they would alter the state relative
to the prior (cached) state.

The best fix for this is to apply alterations on top of the cached
state, rather than trying to determine whether an alteration is
important. Unfortunately, the only way to do this is to defer
alterations until after we can load the cache, which somewhat defeats
one of the original goals of reducing the number of mechanisms by which
alterations are recorded.

Modify how we handle diagnostic alterations to map them through a helper
function, which either defers them (in Project mode) or acts as a
pass-through (applying the changes immediately, in all other modes).
While this does, as noted, introduce another means of storing
diagnostics, this new storage effectively consists of a list of deferred
function calls, rather than a unique format for recording changes, which
is what we had prior to the Great Refactor.
2026-07-22 15:29:59 -04:00
Martin Duffy 593c4ccaa6 CMAKE_TEST_BUILD_DEPENDS: Use config when evaluating test dependency targets
Fixes: #27979
2026-07-22 10:17:54 -04:00
Brad King 6a5e95f6c5 Merge topic 'ctest-configure-avoid-unused-cli-warning' into release-4.4
72eac83626 ctest: Avoid unused-cli warning when propagating SITE/BUILDNAME

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12299
2026-07-21 15:15:28 -04:00
Brad King 031bc0d03f Merge topic 'try_compile-enabled-languages' into release-4.4
39cc425791 try_compile: Restore toleration of toolchain file setting internal variable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12300
2026-07-21 10:07:54 -04:00
Brad King 1a58fc5bb9 Merge topic 'FindPython-fix-SABIModule-detection' into release-4.4
5fdfb2283a FindPython: fix SABIModule detection failure

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12285
2026-07-21 10:05:45 -04:00
Brad King b47fd840fe Merge topic 'gtest-multiple-discovery' into release-4.4
c3c95f3010 GoogleTest: Avoid generation error on duplicate target test discovery

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12279
2026-07-20 15:09:04 -04:00
Brad King bfead65aac Merge topic 'gtest-test-target' into release-4.4
4f0dea4ea5 Merge branch 'backport-4.2-gtest-test-target' into gtest-test-target
fc1b218b37 GoogleTest: Fix gtest_discover_tests race on POST_BUILD of multiple targets
e79506fadf GoogleTest: Fix gtest_discover_tests race on POST_BUILD of multiple targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12276
2026-07-20 15:05:16 -04:00
Brad King 39cc425791 try_compile: Restore toleration of toolchain file setting internal variable
Prior to commit 243462fafe (try_compile: Tolerate compile features from
non-enabled languages, 2026-05-18, v4.4.0-rc1~84^2) we accidentally
tolerated toolchain files setting `CMAKE_<LANG>_COMPILER_LOADED`.
Meson accidentally relied on this, so restore toleration of it.

Fixes: #27971
2026-07-20 14:52:47 -04:00
Tyler Yankee c3c95f3010 GoogleTest: Avoid generation error on duplicate target test discovery
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
2026-07-20 13:26:08 -04:00
Zack Galbreath 72eac83626 ctest: Avoid unused-cli warning when propagating SITE/BUILDNAME
Commit 433721b7a7 (ctest: Pass CTEST_SITE/CTEST_BUILD_NAME to configure
step, 2026-06-15) updated ctest_configure() to pass `-DSITE=...` and
`-DBUILDNAME=...` to the configure command whenever CTEST_SITE or
CTEST_BUILD_NAME are set. Projects that don't include the CTest module never
reference these cache variables, causing CMake to report an unused-cli warning.

Use `-C <initial-cache>` instead of `-D` to seed SITE/BUILDNAME. Cache entries
set using `-C` are not tracked by CMake's unused-cli diagnostic, so projects
using the CTest module still get DartConfiguration.tcl populated correctly,
while projects that never reference SITE/BUILDNAME no longer see the warning.

Fixes: #27953
2026-07-20 13:21:00 -04:00
Tyler Yankee fc1b218b37 GoogleTest: Fix gtest_discover_tests race on POST_BUILD of multiple targets
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
2026-07-20 11:21:35 -04:00
Brad King 062fe1d224 Merge topic 'ctest-junit-exit-error' into release-4.4
0d320cb496 ctest: Exit nonzero when write to output JUnit or XML fails

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12282
2026-07-20 09:56:01 -04:00
Brad King cbd1371db3 Tests: Update RunCMake.Framework expected output for macOS 26.4
The archiver output in the case of universal binaries has changed
slightly.  Update our expected output to match.
2026-07-18 22:26:28 -04:00
Vito Gamberini 82683ae8b0 c++modules: discover synth targets for all configs
Fixes: #26312
2026-07-16 12:10:02 -04:00
Marc Chevrier 5fdfb2283a FindPython: fix SABIModule detection failure
Fixes: #27950
2026-07-16 17:28:43 +02:00
Tyler Yankee 0d320cb496 ctest: Exit nonzero when write to output JUnit or XML fails
`ProcessHandler` can return -1, 0, or 1, and the latter is used in this
particular case.

Fixes: #27949
2026-07-15 15:56:03 -04:00
Brad King 1f3b0f6c0a Merge topic 'ninja-swift-cldeps-order' into release-4.4
9d7da095fd Ninja: Restore cmcldeps command-line ordering

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12270
2026-07-15 10:57:30 -04:00
Tyler Yankee 9d7da095fd Ninja: Restore cmcldeps command-line ordering
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
2026-07-14 12:32:21 -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
Brad King b51b613e7d Merge topic 'trace-ninja-dashc' into release-4.4
727522d835 instrumentation: Fully resolve compile trace path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12257
2026-07-09 13:19:07 -04:00
Brad King e9e1e16512 Merge topic 'fix-not-found-file-set-crash' into release-4.4
d9b9b4cd27 FileSets: Don't crash if a file's file set isn't found

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12255
2026-07-09 09:56:37 -04:00
Tyler Yankee 727522d835 instrumentation: Fully resolve compile trace path
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.
2026-07-09 09:43:18 -04:00
Matthew Woehlke d9b9b4cd27 FileSets: Don't crash if a file's file set isn't found
File sets currently have issues with files containing semicolons;
particularly, names get mangled differently in different contexts. This
can result in failing to find a file's file set. Prior to dee8799d16
(FileSet management: Introduce dedicated classes for generation,
2026-02-16, v4.4.0-rc1~691^2), we guarded against this, but the
aforementioned commit introduced code that would try to use the found
fileset object without checking if it was valid. Add the missing checks
so that we do not crash trying to dereference a null pointer. Also,
refactor `cmGeneratorTarget::GetSourceFilePaths` to avoid unnecessary
work.

Fixes: #27924
2026-07-08 12:30:17 -04:00
Jocó Mihalicza e733da51ba CMP0194: Fix policy number in warning text 2026-07-07 15:58:19 -04:00