14344 Commits
Author SHA1 Message Date
Brad King f4e378278b Merge topic 'cmp0181-trycompile-policy-order'
5e52f92a2a try_compile: Add support for toolchain files to query CMP0181

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12540
2026-09-23 13:47:31 -04:00
Brad King bb13ddbfe1 Merge topic 'install-name-dir-no-separator-conversion'
726e6454b5 Ninja,Makefile: Do not convert separators in the install-name directory

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12530
2026-09-23 13:46:15 -04:00
Brad King 2975be1a6b Merge topic 'procmetrics-command-chain'
1528113bdf instrumentation: Prevent inherited process metrics in chained commands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12513
2026-09-23 13:40:51 -04:00
Brad King 6498b76d61 Merge topic 'reduce-realloc-clang-tidy-part3'
0aa1eaf506 Source: Reduce string allocations, part 4
1d2f0120be Source: Reduce string allocations, part 3
cb20c5bd89 Source: Reduce string allocations, part 2

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12538
2026-09-23 13:30:55 -04:00
Brad King a399d4c1ea Merge topic 'install-TARGETS-RUNTIME_DEPENDENCY_TARGETS'
53019cd2e6 install(TARGETS): Add option to install runtime deps built as other targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12483
2026-09-23 13:22:51 -04:00
Brad King 356af0e38a Merge topic 'capabilities-instrumentation'
a2643a6db6 instrumentation: Add instrumentation version to cmake -E capabilities

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Tyler Yankee <tyler.yankee@kitware.com>
Merge-request: !12536
2026-09-23 11:41:20 -04:00
Florent Castelli 726e6454b5 Ninja,Makefile: Do not convert separators in the install-name directory
The Ninja and Makefile generators passed the install-name directory of a
shared library (`@rpath/` by default, or `INSTALL_NAME_DIR`) through
`ConvertToOutputFormat(SHELL)`.  That converts directory separators for
the host shell, so a Windows host cross-compiling for macOS wrote
`-install_name @rpath\libfoo.dylib`.  The install name is not a host
path: it is embedded in the Mach-O load command and read by dyld on the
target, where a backslash never matches anything.

Escape the value for the shell without converting separators, in both
generators.  Add a test to each that fakes an install-name platform and
checks the generated build files keep the forward slashes.

Fixes: #28104
2026-09-22 14:29:50 -04:00
Brad King 5e52f92a2a try_compile: Add support for toolchain files to query CMP0181
Follow the approach from commit 92320466dd (try_compile: Restore
platform-default link flags in pre-CMP0210 projects, 2026-08-22)
to make the CMP0181 policy setting available in `try_compile`
projects before the toolchain file is loaded.

Fixes: #28108
2026-09-22 11:35:05 -04:00
Stepanov Igor 53019cd2e6 install(TARGETS): Add option to install runtime deps built as other targets
Add a `RUNTIME_DEPENDENCY_TARGETS` option for `install(TARGETS)`
to automatically install the necessary runtime shared libraries.

Closes: #23505
2026-09-22 10:40:52 -04:00
Brad King ec85176fbe Merge topic 'if-RULE-operator'
d4dc18c01b if() command: add RULE operator

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12529
2026-09-22 10:16:47 -04:00
Brad King d37a1fc335 Merge topic 'automoc-predefs-msvc'
7c3ca57b91 MSVC,Clang: Set CMAKE_CXX_COMPILER_PREDEFINES_COMMAND for the MSVC ABI
0fd711348c Autogen: Pass WIN32 to moc when targeting the MSVC ABI
4a4a654814 Autogen: Keep stderr out of the generated moc_predefs.h
1c1258ad95 cmWorkerPool: Allow capturing process stderr separately

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12517
2026-09-22 10:14:46 -04:00
Brad King 6e1b603032 Merge topic 'cmctg-launcher-vector-cleanup'
721eb8a5a2 cmCommonTargetGenerator: Improve launcher shell conversion
bf1a2de409 cmCommonTargetGenerator: Improve style

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12528
2026-09-22 10:08:26 -04:00
Brad King 2020c66db9 Merge topic 'ctest-fixture-repeat'
5cced02b9d CTest: Repeat test fixtures with the tests that require them
4fcf3dd296 CTest: Ignore a checkpoint entry for a test that is not pending
32b25b94d6 CTest: Track one run number for a repeating test

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !11638
2026-09-22 10:01:43 -04:00
Brad King 3a8d7c8e8c Merge topic 'new-fuzzer-3'
8932f356bd OSS-Fuzz: Add new fuzzer targets pkg Config Resolver

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Vito Gamberini <vito.gamberini@kitware.com>
Merge-request: !12531
2026-09-22 09:58:04 -04:00
Martin Duffy 1528113bdf instrumentation: Prevent inherited process metrics in chained commands
Shells may exec the final chained command instead of forking it,
preserving resource usage accumulated from earlier children.

When processMetrics is enabled, append a shell builtin to generated
command chains and scripts for Ninja, Makefiles, and FASTBuild to prevent
this optimization while preserving command exit status.
2026-09-22 09:36:44 -04:00
Martin Duffy a2643a6db6 instrumentation: Add instrumentation version to cmake -E capabilities 2026-09-22 08:39:58 -04:00
AJIOB 0aa1eaf506 Source: Reduce string allocations, part 4 2026-09-22 11:37:41 +03:00
Arthur Chan 8932f356bd OSS-Fuzz: Add new fuzzer targets pkg Config Resolver
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
2026-09-21 18:02:35 -04:00
Robert Maynard 00388f8576 cmake-cli: Deprecate -H
Fixes: #18341
2026-09-21 14:35:51 -04:00
Tyler Yankee 721eb8a5a2 cmCommonTargetGenerator: Improve launcher shell conversion
Encapsulate the shell escaping logic in `cmCommonTargetGenerator` and
represent launchers via a vector of strings (as is done with custom
commands, execute process commands, etc.) to make them easier to work
with.

This facilitates work in a future commit which will reuse this pathway.

Issue: #27598, #27402
2026-09-21 13:45:54 -04:00
Brad King 106b5b5fd7 Merge topic 'cmp0210-trycompile-policy-order'
af7a370bf1 Merge branch 'backport-4.3-cmp0210-trycompile-policy-order'
92320466dd try_compile: Restore platform-default link flags in pre-CMP0210 projects

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12525
2026-09-21 13:41:59 -04:00
Marc Chevrier d4dc18c01b if() command: add RULE operator 2026-09-21 18:10:48 +02:00
Brad King af7a370bf1 Merge branch 'backport-4.3-cmp0210-trycompile-policy-order' 2026-09-21 11:47:20 -04:00
Brad King c512ae97ce Merge topic 'custom-rule-support'
386d1d874c Add support of custom rules

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12361
2026-09-21 11:40:22 -04:00
Mickaël Germain 92320466dd try_compile: Restore platform-default link flags in pre-CMP0210 projects
The CMP0210 compatibility shims in the Darwin, AIX, HP-UX and ARMClang
modules read the policy with cmake_policy(GET CMP0210 ...) during
enable_language(), which runs inside project().  cmCoreTryCompile emitted
cmake_policy(SET CMP0210 ...) after project() in the generated test
project, so those shims always observed NEW regardless of the calling
project's setting.

On affected platforms this dropped the platform default link flags from
every try_compile, and left a toolchain-file value of
CMAKE_<LANG>_LINK_FLAGS unclobbered so that it reached the OLD code path.
For projects that are also not using CMP0181 NEW, that path uses the
variable as is and does not expand the LINKER: prefix.

Move the emission into the existing pre-project() policy block alongside
CMP0126, CMP0128 and CMP0197, which exist for exactly this reason.

Fixes: #28102
2026-09-21 11:35:38 -04:00
Brad King 0b9b66d056 Merge topic 'test-langs-launchers'
584a9297c0 CUDA, HIP: Restore support for LINKER_LAUNCHER
aeb7c3295d Merge branch 'backport-test-langs-launchers' into test-langs-launchers
b63bcda722 CUDA, HIP: Revert false support for LINKER_LAUNCHER

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12519
2026-09-21 11:28:32 -04:00
Marc Chevrier 386d1d874c Add support of custom rules
Fixes: #27383
2026-09-20 11:43:10 +02:00
Taylor Braun-JonesandTyler Yankee 5cced02b9d CTest: Repeat test fixtures with the tests that require them
When ctest repeats tests with its --repeat option, it repeats each test
on its own.  A fixture's setup and cleanup tests therefore run all of
their repetitions back to back, and the tests they bracket repeat inside
a single setup/cleanup pair:

  setup -> setup -> test -> test -> cleanup -> cleanup

Add a FIXTURE_REPEAT_MODE test property to select how a fixture behaves
when its tests are repeated:

* AROUND_ALL_REPEATS: the fixture runs once, around all repetitions of
  the tests requiring it.
* AROUND_EACH_REPEAT: the fixture and the tests requiring it repeat
  together, so every repetition gets a fresh setup and its own cleanup.
* EACH_TEST_SEPARATELY: every test repeats on its own, as before.

The property describes the fixture rather than the test carrying it, so
setting it on any one of a fixture's setup or cleanup tests is enough.

In AROUND_EACH_REPEAT mode the tests of a fixture form a repeat group that
ctest re-queues as a whole once every test in it has finished.  The --repeat
condition then applies to the group the way it applies to an individual
test: until-fail repeats while the whole group passes, until-pass repeats
while any of it does not, and after-timeout repeats while any of it times
out.  Fixtures that share a test repeat together, so a test requiring two of
them still runs once per repetition.

A group is recorded the way a repeating test is: only once it stops
repeating, and with the results of its last repetition.  A group that
until-pass makes pass therefore reports a pass rather than the failure that
made it repeat, a test that DEPENDS on one of the group's tests waits for
the last repetition rather than the first, and `ctest -F` resumes an
interrupted group by running it again from the beginning.

Fixtures that repeat together have to agree on the mode: a test cannot
repeat with one fixture but not with another it takes part in, and a fixture
whose setup and cleanup tests disagree has no coherent behavior.  Report an
error and run nothing in those cases rather than pick an order in which a
test repeats after a fixture it requires has been cleaned up.

Add policy CMP0224 to select AROUND_EACH_REPEAT as the default for fixtures
whose setup and cleanup tests choose no mode themselves.  Record the mode
the policy chose in the generated test file under its own
_CMAKE_DEFAULT_FIXTURE_REPEAT_MODE keyword, so that ctest reads a mode
rather than the policy settings behind it, and so that a mode requested on
one of a fixture's tests wins over the default recorded for its siblings.
Only NEW needs recording: with nothing recorded, ctest already uses the
behavior of CMake 4.4 and below.  Fixtures are common, and the choice of
mode matters only to those who run ctest --repeat, so warn about the unset
policy only when the CMAKE_POLICY_WARNING_CMP0224 variable asks for it.

discover_tests() and gtest_discover_tests() create their tests while ctest
runs or at build time, too late for the policy to reach them, so carry the
setting in effect at their call sites through to the tests they create.

Report the repetition a grouped test belongs to in the "(run N/M)" suffix
of its "Start" line, as ctest already does for a test repeating on its own.

Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
Fixes: #21438
2026-09-18 08:29:28 -04:00
Brad King 670f62d10d Merge topic 'cmake_path-empty-prefix'
7192a2b798 cmake_path: An empty path is not a prefix of any path

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12493
2026-09-18 08:16:12 -04:00
Brad King f9ae489598 Merge topic 'cdash-instrumentation-proc-metrics'
01fa1984e5 instrumentation: Send processMetrics data to CDash
68e2a3e793 instrumentation: Rename userTime and systemTime fields to exclude units

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Tyler Yankee <tyler.yankee@kitware.com>
Merge-request: !12514
2026-09-18 08:11:50 -04:00
Brad King 50b4f2f8bb Merge topic 'instrumentation-test-fix-spam'
ff48c8d4d2 Tests/Instrumentation: Fix exponential output spam from validate_json_schema

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12515
2026-09-18 08:10:10 -04:00
Brad King fb4bab8ee5 Merge topic 'ninja-codegen-deps-fix'
2d85779126 Ninja: Account for explicit target dependencies via CODEGEN

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12512
2026-09-18 08:07:25 -04:00
Brad King ab46a992e5 Merge topic 'ctest-dashboard-preset-env'
27f28db197 Help: Clarify CTEST_NO_TESTS_ACTION support and interaction
a235560e53 Help: Clarify interaction between CTest parallelism toggles
f745dd11ab ctest: Respect test envvars set by CTEST_PRESET
277236a99a cmCTestTestCommand: Factor out preset resolution
81b46d87ba cmCTest: Factor out environment variable handling
4e81913645 Tests: Fix unset(ENV{...}) typos

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12495
2026-09-18 07:59:56 -04:00
Joerg Bornemann 7c3ca57b91 MSVC,Clang: Set CMAKE_CXX_COMPILER_PREDEFINES_COMMAND for the MSVC ABI
The variable was only set by the GNU-like compiler modules, so AUTOMOC
never generated a moc_predefs.h for compilers targeting the MSVC ABI
and moc parsed headers without the compiler's predefined macros.

MSVC dumps its predefined macros with '/PD', which needs the conforming
preprocessor. Require VS 2019 16.8, because 16.7 and older ignore the
flag with warning D9002 and emit no macros at all. clang-cl takes '-dM'
through '-Xclang'. Both also echo the preprocessed source, so feed them
an empty translation unit. clang with the GNU driver is excluded from
'Compiler/GNU' as well when it simulates MSVC, so give it the usual
'-dM -E' command there.

Fixes: #28093
2026-09-18 11:35:02 +02:00
Tyler Yankee 584a9297c0 CUDA, HIP: Restore support for LINKER_LAUNCHER
Reapply the implementation in commits 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).

Add a special case to expand the correct rule placeholder for these
languages, which is spelled `CMAKE_<LANG>_HOST_LINK_LAUNCHER`. Enable
the tests for these languages correctly. Re-document support under
CMake 4.5.

Fixes: #26967
2026-09-17 18:11:42 -04:00
Tyler Yankee aeb7c3295d Merge branch 'backport-test-langs-launchers' into test-langs-launchers 2026-09-17 18:08:42 -04:00
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
Martin Duffy 01fa1984e5 instrumentation: Send processMetrics data to CDash 2026-09-17 10:29:06 -04:00
Martin Duffy 68e2a3e793 instrumentation: Rename userTime and systemTime fields to exclude units
Drop the "USec" suffix from these fields for consistency with other
instrumentation fields which do not include units.
2026-09-17 10:10:31 -04:00
Mickaël Germain 7192a2b798 cmake_path: An empty path is not a prefix of any path
cmake_path(IS_PREFIX) and $<PATH:IS_PREFIX> treated an empty path as a
prefix of every path, including another empty path, following
std::filesystem::path.  A prefix that is empty because a variable was
set to an empty value, or because a generator expression argument
expanded to nothing, therefore satisfied a check meant to reject it.

Return false for an empty prefix, in cmCMakePath::IsPrefix so that every
caller shares one implementation and both the plain and NORMALIZE forms
are covered.  Normalizing an empty path leaves it empty, so no separate
handling of NORMALIZE is needed.  Unlike the component comparison, which
follows std::filesystem::path deliberately, IsPrefix has no counterpart
in the standard: it borrows path iteration but the predicate itself is
defined by CMake, so an empty prefix is a gap to fill rather than a
standard answer to override.

Add policy CMP0223 and restore the old result behind it at the two
released surfaces.  The other callers of IsPrefix, source_group() and
the Makefile generator's source classification, take the new behavior
ungated: source_group() rejects an empty TREE argument before reaching
it, and the generator passes the source and binary directories.

The if(PATH_IS_PREFIX) operator, new in this same release, follows the
policy too rather than simply taking the new behavior, so that it agrees
with cmake_path(IS_PREFIX) in every policy state and the parity
assertions in its test hold unconditionally.

Fixes: #28077
2026-09-17 10:05:27 -04:00
Brad King a30ad325f4 Merge topic 'instrumentation-cdash-file-check'
77443e7258 instrumentation: Don't expect staged CDash files when cdashSubmit is disabled

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Tested-by: Aiden Woodruff <aiden.woodruff@kitware.com>
Merge-request: !12508
2026-09-16 14:39:28 -04:00
Brad King 61a28e735b Merge topic 'clang-cuda-offload-warn-unsupported'
616f65b379 Clang/CUDA: Warn when using offloading driver with RDC + PTX

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12500
2026-09-16 13:44:17 -04:00
Martin Duffy ff48c8d4d2 Tests/Instrumentation: Fix exponential output spam from validate_json_schema
Schema validations in Tests/Instrumentation called add_error("${RunCMake_TEST_FAILED}")
in a loop. Because add_error itself appends the input to RunCMake_TEST_FAILED, this
resulted in exponential growth of error messages on each loop iteration, filling the
test log with duplicate errors.

Isolate error messages from validate_json_schema to avoid exponential duplication.
2026-09-16 13:12:03 -04:00
Tyler Yankee f745dd11ab ctest: Respect test envvars set by CTEST_PRESET
Note the special attention given to support CTest environment variables
from inside a test preset's `environment` field.

Fixes: #28079
2026-09-16 09:34:43 -04:00
Tyler Yankee 4e81913645 Tests: Fix unset(ENV{...}) typos 2026-09-16 08:51:36 -04:00
Brad King 7e798bb389 Merge topic 'cmake-gui-preset-apply-ordering'
fdc2c2b9c7 cmake-gui: settle preset application before Configure/Generate

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12502
2026-09-15 11:29:28 -04:00
Robert Maynard 616f65b379 Clang/CUDA: Warn when using offloading driver with RDC + PTX
Fixes: #28084
2026-09-15 11:01:04 -04:00
Tyler Yankee 2d85779126 Ninja: Account for explicit target dependencies via CODEGEN
When a "normal" target (e.g., an executable) depends on a custom target
that is not part of `all`, and that custom target owns the output of a
custom command marked `CODEGEN`, an explicit `add_dependencies` from
the normal to custom target must be incorporated in `codegen`.

Amends commit 197cb419d1 (add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2), which already incorporated such logic
in the Unix Makefile generator, but was not tested nor implemented for
Ninja.

Fixes: #28092
2026-09-15 10:34:09 -04:00
Brad King a07b6e2a4d Merge topic 'improve-install-code-script'
2673161b67 install: Improve documentation, argument parsing

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12501
2026-09-15 09:58:50 -04:00
Brad King b0499f43d0 Merge topic 'Sources-various-enhancements'
bc4e849e50 cmValue: introduce constants cmValue::True and cmValue::False
a570ee4c8f cmPlaceHolderExpander: Add recognition of genex
b53f05cd8c cmArgumentParser: enhance multi command management
a53691b73a cmCustomCommand: reduce raw pointer usage

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12506
2026-09-15 09:55:15 -04:00