mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmake: Restore finding installed resources in their real path
In commit 0994bc7929 (cmake: Preserve symlinks in references to itself
when possible, 2024-11-11) we stopped looking for resources using the
real path of the directory containing `cmake`. Restore it as a fallback
to support layouts like `/{bin -> usr/bin}/cmake`.
Fixes: #26570
This commit is contained in:
@@ -2984,9 +2984,19 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
|
||||
// Find resources relative to our own executable.
|
||||
std::string exe_dir = cmSystemTools::GetFilenamePath(exe);
|
||||
bool found = false;
|
||||
// When running through a symlink to our own executable,
|
||||
// preserve symlinks in directory components if possible.
|
||||
do {
|
||||
found = FindCMakeResourcesInInstallTree(exe_dir);
|
||||
} while (!found && ResolveSymlinkToOwnExecutable(exe, exe_dir));
|
||||
// If we have not yet found the resources, the above loop will
|
||||
// have left 'exe' referring to a real file, not a symlink, so
|
||||
// all our binaries should exist under 'exe_dir'. However, the
|
||||
// resources may be discoverable only in the real path.
|
||||
if (!found) {
|
||||
found =
|
||||
FindCMakeResourcesInInstallTree(cmSystemTools::GetRealPath(exe_dir));
|
||||
}
|
||||
if (!found) {
|
||||
FindCMakeResourcesInBuildTree(exe_dir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user