mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Since commitae373e93fb(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 commitc6e6861e63(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
4 lines
114 B
CMake
4 lines
114 B
CMake
cmake_policy(SET CMP0074 NEW)
|
|
set(Outer_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/NestedConfig)
|
|
find_package(Outer CONFIG)
|