1b946dfbfe Merge branch 'backport-4.2-find_package-stack' into find_package-stack
e8ae3645db Merge branch 'backport-4.2-find_package-stack' into find_package-stack
aae02ee60a find_package: Share package information among copies of package stack
a789c21100 Merge branch 'backport-4.2-find_package-stack' into find_package-stack
9387988626 find_package: Save package information only after successfully loading it
561ece2407 cmFindPackageStack: Restore pure value semantics
e935ed22fb find_package: Share package information among copies of package stack
5aa649d5f6 find_package: Save package information only after successfully loading it
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11887
Since commit ae373e93fb (install(PACKAGE_INFO): Add version and location
to package dependencies, 2025-07-31, v4.2.0-rc1~340^2) we add package
information to the current package's stack entry as it is discovered.
However, a nested package can cause the current package's stack entry to
be replaced by a copy with a new ordering index due to commit c6e6861e63
(install(EXPORT): Export find_dependency() calls, 2023-11-07,
v3.29.0-rc1~439^2~1). Depending on whether imported targets were
created by the current package before finding the nested package, the
`CurrentPackageInfo` pointer is either invalidated, or left pointing at
only one of multiple copies.
Fix this by sharing a single instance of package information with all
copies of the current package's stack entry. Keep a mutable pointer
to the current package's information only while it is still pending.
This also avoids the need to expose mutation from the package stack.
Add a test that exposes the previously-invalidated pointer to dynamic
analysis tools.
Fixes: #27730
If a package configuration file sets `<PackageName>_FOUND` to false,
the package is considered not found. Do not save its package info.
Note that this exposes an existing pointer invalidation on nested
`find_package` calls, which will be fixed in following commits.
Issue: #27730
A stack entry's storage may be shared by other copies, so mutation is
incompatible with value semantics. We've migrated the motivating use
case to another approach.
Revert commit b3873b8272 (cmFindPackageStack: Allow controlled mutation,
2025-07-29, v4.2.0-rc1~438^2) and commit f2bdc2176f (cmStack: New,
mutable stack class, 2025-07-29, v4.2.0-rc1~438^2~1). Record their
parent as a second parent of this commit so `git blame` can see the
original history of the restored content.
If a package configuration file sets `<PackageName>_FOUND` to false,
the package is considered not found. Do not save its package info.
Note that this exposes an existing pointer invalidation on nested
`find_package` calls, which will be fixed in following commits.
Issue: #27730
Since commit ae373e93fb (install(PACKAGE_INFO): Add version and location
to package dependencies, 2025-07-31, v4.2.0-rc1~340^2) we add package
information to the current package's stack entry as it is discovered.
However, a nested package can cause the current package's stack entry to
be replaced by a copy with a new ordering index due to commit c6e6861e63
(install(EXPORT): Export find_dependency() calls, 2023-11-07,
v3.29.0-rc1~439^2~1). Depending on whether imported targets were
created by the current package before finding the nested package, the
`CurrentPackageInfo` pointer is either invalidated, or left pointing at
only one of multiple copies.
Fix this by sharing a single instance of package information with all
copies of the current package's stack entry. Keep a mutable pointer
to the current package's information only while it is still pending.
This also avoids the need to expose mutation from the package stack.
Add a test that exposes the previously-invalidated pointer to dynamic
analysis tools.
Fixes: #27730
c386aaebf8 FILE_SET: install and export SOURCES file set type
5c5b68f44e FILE_SET: Add support for the SOURCES type
5697bcced0 BT<> and cmLocalGenerator: Add helpers functions
42ca2a2062 cmEvaluatedTargetProperty: put declarations in namespace cm
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11863
7ebb5687ab cmGeneratorTarget: use typename for `flag`
4a4986d28a cxxmodules: support command templates for BMI compilation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11871
Some compilers (Clang) warn when using their BMI-only flag with `-c`.
Support a complete template for BMI compilation rather than an
additional flag to support such toolchains.
Fixes: #27600
680fbb112a Autogen: Enable depfile support for Visual Studio and Xcode generators
d9f569c246 Autogen: Skip per-compilation dep reading when depfile merge is used
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11844
Extend the depfile-based AUTOGEN incremental build support to Visual
Studio and Xcode generators, in addition to the existing Ninja and
Makefile support. Use generator name matching rather than
SupportsCustomCommandDepfile() to select generators explicitly, because
not all generators that claim depfile support handle the resulting build
graph correctly. In particular, when depfiles are used, CMake introduces
a _autogen_timestamp_deps utility target to express ordering constraints,
and the FASTBuild generator does not correctly propagate dependencies
through utility targets that have no commands, breaking the build when
generated files are AUTOMOC inputs.
When depfiles are used, disable the PRE_BUILD optimization for Visual
Studio because PRE_BUILD events cannot carry depfile dependencies.
Fixes: #25233Fixes: #25234