3390 Commits
Author SHA1 Message Date
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
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 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
Martin Duffy a2643a6db6 instrumentation: Add instrumentation version to cmake -E capabilities 2026-09-22 08:39:58 -04:00
Marc Chevrier d4dc18c01b if() command: add RULE operator 2026-09-21 18:10:48 +02: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
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
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
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 f5efe7a6b5 Merge topic 'xcode-embed-genex'
90c03329dd Xcode: Honor generator expressions in XCODE_EMBED_<type>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12499
2026-09-14 10:58:37 -04:00
Tor Arne Vestbø 90c03329dd Xcode: Honor generator expressions in XCODE_EMBED_<type>
Evaluate the XCODE_EMBED_<type> target property through the generator
expression evaluator before building the copy-files phase.  Xcode shares
one copy-files build phase across all configurations, so the embedded set
cannot vary by configuration.  Reject any expression whose result depends
on the configuration, matching the existing per-source diagnostic.

Fixes #28082
2026-09-11 16:45:25 +02:00
Brad King 216cc54531 Merge topic 'AUTOMOC-cxxmodules-support'
6280cc3df9 Autogen: Add AUTOMOC support for C++ module units
266c6f0109 Autogen: Factor out the info-file source-entry reader

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Reviewed-by: Vito Gamberini <vito.gamberini@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !12490
2026-09-11 09:16:10 -04:00
Brad King 34bbc91e3b Merge topic 'if-PATH_IS_PREFIX'
860583ceac if: Add PATH_IS_PREFIX operator
3d53f7901b Tests: Cover cmake_path(IS_PREFIX) path semantics
59a096f73b Tests: Detect a malformed genex in the PATH:IS_PREFIX test

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12427
2026-09-11 09:11:02 -04:00
Joerg Bornemann 6280cc3df9 Autogen: Add AUTOMOC support for C++ module units
Process C++ module interface and partition units that are members of a
FILE_SET of type CXX_MODULES.  moc is run on such units and its
generated output is compiled as a module implementation unit of the same
module, as its own scanned translation unit rather than folded into
mocs_compilation.cpp.  Macro-less units get an empty placeholder; module
units and their dependencies are tracked in the autogen depfile and as
byproducts for correct incremental rebuilds.

This requires Qt 6.13, whose moc supports C++ module units.  With older
Qt nothing can be generated for a module unit, so a meta-object macro
found in one is reported as an error rather than left to fail later in
the compiler or the linker.  Such a unit is no longer handled as an
ordinary source, which also means its moc include directives are not
honored and AUTOUIC does not process it.

moc rejects a meta-object macro in a module implementation unit or a
private module fragment, and AUTOMOC does not work around that.
2026-09-10 13:13:11 +02:00
Mickaël Germain 860583ceac if: Add PATH_IS_PREFIX operator
Testing whether one path is a prefix of another is possible today with
cmake_path(IS_PREFIX), but the idiom needs a separate statement plus a
scratch variable and takes the prefix as a variable name, so projects
reach for if(path MATCHES "^${prefix}") instead.  That is wrong whenever
the prefix contains a regex metacharacter, and it accepts siblings,
because '^/a/b' matches '/a/bc'.

Add a binary operator where the left operand is the candidate prefix and
the right is the path, matching the operand order of cmake_path(IS_PREFIX)
and $<PATH:IS_PREFIX> so that the same operation reads the same way on all
three surfaces.  Neither operand is normalized, matching the default of
cmake_path(IS_PREFIX) and the existing PATH_EQUAL operator, so '.' and
'..' are compared as ordinary components.  The test is non-strict, purely
lexical, and applies no relative-to-absolute reconciliation.

Add policy CMP0222 for compatibility, modeled on CMP0139.  The keyword
is consumed as an operator only when it appears in the second argument
slot, so a variable named PATH_IS_PREFIX keeps working in unary and
left-operand position.  What the policy covers is such a variable
appearing after another token, as in if(NOT PATH_IS_PREFIX AND other),
which becomes a configure error under NEW.

Since the operator is an if() spelling of cmake_path(IS_PREFIX) and shares
its implementation, test it by asserting the two agree over a corpus of
inputs rather than by restating expected values.  Those are pinned by the
cmake_path(IS_PREFIX) test, so the operator's tests stay limited to what
has no command equivalent, and no platform branching is needed because
parity holds whatever the host path model answers.

Fixes: #28040
2026-09-10 07:09:47 -04:00
Brad King 61a5b7846b Merge topic 'clang-cuda-offload-linker'
5b416cbe77 ci: add job testing cuda13.2 with clang
64dac60df9 ci: Update cuda13.2-x86_64 base image to clang-23
ce3d0af576 Clang/CUDA: Support the llvm23+ offload linker model

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12052
2026-09-07 08:45:35 -04:00
Craig Scott 75b0c94ad3 Merge topic 'fileapi-interface-includes'
484cac3916 File API: Add interfaceIncludes field

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12352
2026-09-06 19:03:04 -04:00
Martin Duffy 484cac3916 File API: Add interfaceIncludes field
Fixes: #28006
2026-09-04 11:54:02 +10:00
Robert Maynard ce3d0af576 Clang/CUDA: Support the llvm23+ offload linker model
Fixes: #26120, #26810
2026-09-03 13:26:45 -04:00
Brad King 99079ccab6 Merge topic 'chsi-distrib-host-vs-target'
52c8b8104b cmake_host_system_information: select host vs sysroot for DISTRIB_*

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex Turbov <i.zaufi@gmail.com>
Merge-request: !12453
2026-09-03 09:04:03 -04:00
Daksh Mamodiya 52c8b8104b cmake_host_system_information: select host vs sysroot for DISTRIB_*
`DISTRIB_*` read os-release under `CMAKE_SYSROOT`, so cross builds got
the target distro from a host-oriented command, and a process-wide
static froze the first result.  Add a `FROM_SYSROOT <bool>` option and
policy `CMP0221` to default to the host, parse per call, and scope
`CMAKE_SYSROOT` so the fallback scripts follow the same choice.

Fixes: #27640
2026-09-02 14:48:36 +02:00
Maximilian Sander 02dd870535 presets: Add configurePresetName macro
Fixes: #28028
2026-08-25 14:33:10 -04:00
Brad King a584d8ed75 Merge topic 'system-env-id'
fc3c71d11f cmake: Add cached environment id that triggers reconfigure when changed

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12420
2026-08-25 11:47:48 -04:00
Aiden Woodruff fc3c71d11f cmake: Add cached environment id that triggers reconfigure when changed
The opaque `CMAKE_SYSTEM_ENVIRONMENT_ID` variable is cached during the
first invocation of `cmake` and is a user-defined hint about the state
of the environment. When the value changes, `cmake` either does nothing,
emits a warning (by default), or refreshes the cache as if by `--fresh`.
The action is controlled by the `CMAKE_SYSTEM_ENVIRONMENT_ACTION`
environment variable (which is not cached).

Implements: #28025
2026-08-24 15:06:35 -04:00
Brad King e903d46b9a Merge topic 'install-TARGETS-default-MODULE'
8072e80f4b install(TARGETS): Add default destination for MODULE libraries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12403
2026-08-24 12:27:07 -04:00
Brad King 568b7bee83 Merge topic 'presets-list-defined'
2a9cde8b6e presets: Add defined listings with unavailable reasons

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12367
2026-08-24 12:22:13 -04:00
Brad King 3ed98a45a8 Merge topic 'makefiles-output-sync'
e135fd8e44 Makefiles: Group parallel build output via GNU Make --output-sync

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12399
2026-08-24 12:19:01 -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
Robert Maynard a2e6306c27 GenEx/LINK_LIBRARY: Add NEEDED_LIBRARY support on Linux 2026-08-13 13:45:19 -04:00
Tom Osika 8072e80f4b install(TARGETS): Add default destination for MODULE libraries
Installing a module target without a LIBRARY DESTINATION no longer
raises an error. On DLL platforms, the default destination is the
RUNTIME default. Otherwise, the LIBRARY default is used.

Closes: #27759
2026-08-13 10:55:07 -04:00
15daksh-2003 e135fd8e44 Makefiles: Group parallel build output via GNU Make --output-sync
A parallel `cmake --build` with a Makefiles generator interleaved the
output of concurrent recipes.  When CMake is the one passing the
parallel flag and a build-time probe finds GNU Make 4.0 or newer,
append `-Otarget` so each recipe's output stays grouped.  A native
`-- -j` leaves the job count unset and opts out.

Honor `USES_TERMINAL` under grouping by prefixing such recipes with a
`$(CMAKE_USES_TERMINAL_PREFIX)` variable, empty by default and set to
`+` next to `-Otarget`, so interactive commands stay unbuffered.

Fixes: #27510
2026-08-13 10:00:13 -04:00
Tom Osika 048ee670f2 cmake_print_properties: Deprecate in favor of cmake_language(PRINT_PROPERTIES)
Re-implement it in terms of the replacement command.

Issue: #27513
2026-08-10 17:45:47 -04:00
Tom Osika 2a2012e913 cmake_language: Add PRINT_PROPERTIES operation
Print CMake entities' properties in human-readable form for debugging.

Issue: #27513
2026-08-10 17:41:05 -04:00
Brad King fd093f59e7 Merge topic 'string-json-array-split'
7cca8540ca string(JSON): Add ARRAY_SPLIT mode for linear array iteration

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12386
2026-08-08 10:49:20 -04:00
Brad King 628ceffe6b Merge topic 'enable-language-subdirectory'
86759dce81 enable_language: add support for usage in subdirectories
220fc8622d block: Fix incorrect policy scope creation order

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12222
2026-08-08 10:45:42 -04:00
Brad King ebd3af92f9 Merge topic 'print_variables'
4f09a029dc cmake_print_variables: Deprecate in favor of cmake_language(PRINT_VARIABLES)
a06658b6d7 cmake_language: Add PRINT_VARIABLES operation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12160
2026-08-07 11:48:00 -04:00
Daksh Mamodiya 7cca8540ca string(JSON): Add ARRAY_SPLIT mode for linear array iteration
Iterating a JSON array with GET re-parses the entire string on every
call, so walking N elements is O(N^2).  ARRAY_SPLIT parses the array
once and returns its elements as a CMake list, letting each element be
queried individually in linear total time.

Each element is re-serialized as compact JSON and encoded to survive
CMake list parsing: '[' and ']' inside strings are emitted as \u005B
and \u005D, and ';' is escaped as '\;'.  Every element therefore stays
valid, re-queryable JSON.

Fixes: #27985
2026-08-07 17:45:50 +02:00
Arha Gatram 86759dce81 enable_language: add support for usage in subdirectories
Propagates variables set in enable_language() logic up variable scopes
so that the language can be used by targets in the ancestor directories.
Works through block() and function() scopes as well. The
add_subdirectory() call can be thought of as the effective call site for
enabling the language. The same holds for endblock() and the actual
function call.

Adds a policy CMP0220 to control this behavior. As the language is
"enabled" at each ancestor scope, the policy is checked. If OLD, the
language is not enabled at this scope and the ones above.

Closes: #27881 #27508 #27389
Related: #26751 #27564
2026-08-07 11:05:57 -04:00
Tom Osika 4f09a029dc cmake_print_variables: Deprecate in favor of cmake_language(PRINT_VARIABLES)
Re-implement it in terms of the replacement command.

Issue: #27513
2026-08-07 10:57:01 -04:00
Marc Chevrier 8c0bb8ee95 FindPython: Add support for python specific crosscompiling emulator
Fixes: #27996
2026-08-06 17:57:26 +02:00
Tom Osika a06658b6d7 cmake_language: Add PRINT_VARIABLES operation
Print CMake variables in human-readable form for debugging.

Issue: #27513
2026-08-05 14:45:44 -04:00
Brad King fc5ff503cf Merge topic 'ctest-json-test-prop-raw'
572e4b5d2a ctest: Add --show-only=json-v1-raw option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12288
2026-08-04 10:53:33 -04:00
Arha Gatram 572e4b5d2a ctest: Add --show-only=json-v1-raw option
This option changes the JSON value field for test properties to use the
unparsed string value.

Fixes: #27958
2026-08-03 09:36:11 -07:00
Marc Chevrier 91e227939c FindPython: Add Python_SOSABI_PLATFORM variable
This variable gives the SABI module extension which include the
platform triplet.

Fixes: #27997
2026-07-31 16:41:01 +02:00
Brad King 8a947d73d5 Merge topic 'warn-non-target-directives'
00959286b9 Diagnostics: Warn about non-target directives

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12172
2026-07-29 10:34:27 -04:00