CMakePackageConfigHelpers: Save/restore PACKAGE_PREFIX_DIR
Before this change, the following calls can result in PACKAGE_PREFIX_DIR
being modified in the caller's scope:
find_package()
-
find_dependency()
(since it callsfind_package()
) generate_apple_platform_selection_file()
generate_apple_architecture_selection_file()
The two generate_apple_..._selection_file()
commands call configure_package_config_file()
internally, which will set a new PACKAGE_PREFIX_DIR
. A find_package()
or find_dependency()
call can result in reading a config file for that dependency which was generated by configure_package_config_file()
too, again setting a new PACKAGE_PREFIX_DIR
.
The changes in this MR save and restore the value of PACKAGE_PREFIX_DIR
in each of the above four cases. If projects are calling configure_package_config_file()
and including the generated file in cases outside of the above, the project will be responsible for saving and restoring PACKAGE_PREFIX_DIR
itself (like it is now).
Fixes: #25827 (closed)
Backport: release:HEAD~2