cmake: Preserve symlinks in references to itself when possible
CMake's tools search relative to their own locations to find their
resources. Previously they always started at their own `realpath()`.
The intention was to support invocation through symbolic links to the
binaries where the resources can only be found under the real prefix:
/logical/prefix/bin/cmake -> /real/prefix/bin/cmake
/real/prefix/share/cmake
The generated build system refers to CMake's own tools and resources
through the `/real/prefix`. This is not desirable in the case that the
`/logical/prefix` is meant as the canonical location and uses symbolic
links for both tools and resources as an implementation detail:
/logical/prefix/bin/cmake -> /real/prefix/bin/cmake
/logical/prefix/share/cmake -> /real/prefix/share/cmake
In this case, the generated build system should refer to CMake's own
tools and resources through the `/logical/prefix`. This way the
`/real/prefix` can be changed, and the symbolic links updated,
without breaking already-generated build systems.
Fixes: #19849
Fixes: #21059
Inspired-by: Carlo Cabrera <github@carlo.cab>
Inspired-by: Rodger Combs <rodger.combs@gmail.com>
1 file changed