install(SBOM) could crash for dependencies outside an export set and
mishandle private dependencies expressed through LINK_ONLY.
Resolve link expressions before target lookup, traverse unexported
dependencies transitively, and isolate document state per configuration.
Preserve target license precedence and align document metadata inheritance
with CPS. Add regression coverage for these cases.
Fixes: #28141Fixes: #28210
Cover additional cases pertaining to add_dependencies:
* dependencies followed through an intermediate target,
* a dependency's non-CODEGEN commands must not run,
* dependencies of EXCLUDE_FROM_ALL targets are not followed,
* a dependency in an EXCLUDE_FROM_ALL subdirectory is reached.
Also verify that codegen re-runs a command only when its inputs change.
The target that runs codegen for all cross-configs was named
`codegen:codegen`. Name it `codegen:all` to follow the documented
`<target>:all` convention, as the `all` target already does.
Amends commit 197cb419d1 (add_custom_command: Add CODEGEN support,
2024-05-27, v3.31.0-rc1~394^2).
Ninja: Since commit 2d85779126 (Ninja: Account for explicit target
dependencies via CODEGEN, 2026-09-15, v4.5.0-rc1~162^2), a directory's
codegen phony depends on the full build of every add_dependencies
target (which caused their non-CODEGEN commands to run). Instead,
depend only on those targets' CODEGEN outputs, and follow their own
codegen dependencies in turn.
Makefiles: Since commit 197cb419d1 (add_custom_command: Add CODEGEN
support, 2024-05-27, v3.31.0-rc1~394^2), a target's `<target>/codegen`
rule used to depend on `<dep>/all` for every add_dependencies target,
which fully built them. Instead, depend on `<dep>/codegen`, except when
the target has CODEGEN commands of its own, in which case it should
still depend on `<dep>/all` as the commands may need the dependency's
outputs.
Shape up the prior `no-codegen` test case, which wasn't verifying much
of anything.
Fixes: #28205
FDO pkg-config does not allow multiple output modes like --modversion
and --variable in the same query. Split them up into two separate
queries while retaining batching for the rest of the flags.
Fixes: #28194
Since commit 7566a477f7 (GNUInstallDirs: Factor out helper for special
absolute path logic, 2025-03-27, v4.1.0), when CMAKE_INSTALL_PREFIX is
under /opt/ (excluding /opt/homebrew), the special case FHS directories
include an extra path separator, resulting in values like /etc//opt/foo.
This is observed in CMAKE_INSTALL_FULL_SYSCONFDIR,
CMAKE_INSTALL_FULL_LOCALSTATEDIR, and CMAKE_INSTALL_FULL_RUNSTATEDIR
whenever their corresponding CMAKE_INSTALL_<dir> may be relative, as is
the case under policy CMP0192 OLD or if set explicitly while under
CMP0192 NEW (e.g. -DCMAKE_INSTALL_SYSCONFDIR=etc). Restore the previous
path calculation, which relies on the prefix starting with `/`.
Fixes: #28186
Since commit 8997bb6431 (install: Parse SCRIPT and CODE arguments with
cmArgumentParser, 2026-08-14, v4.5.0-rc1~190^2) a missing argument to
`install(... COMPONENT)` is an error. Restore the default to the
"Unspecified" component as before.
Fixes: #28177
Enable test preparation targets by default. Add (better named)
`CMAKE_SKIP_TEST_PREP_TARGETS` variable to control generation of the
same, mirroring `CMAKE_SKIP_INSTALL_PREP_TARGETS`. Remove support for
old `CMAKE_TEST_BUILD_DEPENDS` variable. Update and improve
documentation.
This improves consistency between test and install preparation targets.
It also modifies the descriptions of preparation targets in the
documentation of generators which support them to be consistent.
(Previously, each generator described preparation targets in a manner
unique to each generator.)
Fixes: #28050
Commit 1528113bdf (instrumentation: Prevent inherited process metrics in
chained commands, 2026-09-14) added an extra command to successfully
track process metrics for instrumentation, working around shell exec
optimizations . However, this workaround gets exported into
`compile_commands.json` when using the Ninja generator, which breaks
some tools that consume the database.
Append this no-op command only when generating the actual build files.
Since commit 57eed59f35 (CPack/DEB: Use the same compression type for
control tar, 2025-07-29), control.tar uses CPACK_DEBIAN_COMPRESSION_TYPE.
deb(5) allows lzma and bzip2 only for data.tar, so dpkg rejects packages
built with either type. Fall back to gzip for control.tar in those cases,
as before that commit.
Fixes: #28169
The Xcode generator implements `target_precompile_headers()` through the
`GCC_PREFIX_HEADER` build setting, so Clang receives the prefix header as
an `-include` flag and finds the precompiled `.gch` next to it. Clang
honors that only when it is the first `-include` flag. Xcode extracts
every `-include <file>` pair out of settings such as `OTHER_CFLAGS` and
places it on the command line ahead of the prefix header, so a force
include added by the project always came first and the precompiled header
was dropped:
precompiled header '.../cmake_pch.hxx.gch' was ignored
because '-include .../cmake_pch.hxx' is not first '-include'
Pass such flags straight to the compiler front end as a single joined
`-Xclang -include<file>` argument instead. Xcode does not recognize it as
a force include and leaves it in the response file, and the driver no
longer sees an `-include` flag of its own, so the prefix header stays
first. The header is still force included: Xcode compiles the prefix
header in a step of its own, in which every force include, `-Xclang` or
not, is processed before the prefix header itself.
Rewrite every spelling Clang accepts, joined ones such as `-include<file>`
and `--include=<file>` included, since the driver recognizes them all.
Leave alone a flag already handed to a sub-tool with `-Xclang` or
`-Xpreprocessor`, as well as one whose value looks like another flag.
`GCC_PREFIX_HEADER` is a target-wide setting, so apply the rewrite to
every language compiled in the target, not just the one the precompiled
header was requested for. Do it where the `OTHER_*FLAGS` strings are
assembled so that the define flags are covered too. Only rewrite for
languages the prefix header applies to, and for compilers that understand
`-Xclang`.
Fixes: #23259
It has been around since CMake 2.6.3 for generated install scripts but
was never documented. Added a test for the result too, since nothing
checked it before.
Fixes: #28154
Flang gained -Xlinker only in LLVM 20, so the Apple linker flags added
by commit 18d65b9d4b (LLVMFlang: Fix Fortran shared library creation on
Apple platforms, 2026-09-23) fail with older Flang. For those versions
the flags now go through -Wl, with the install name joined to its flag.
Flang 20 and later keep the -Xlinker form.
Fixes: #28148