From 773b75e4ed767230bae2ba69126e176d5162228c Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 23 Oct 2024 09:10:15 -0400 Subject: [PATCH] cmake: Explicitly look up on-disk case of input paths on Windows KWSys's `CollapseFullPath` no longer looks up the actual case on disk. Add the lookup explicitly where we need it: * `ToNormalizedPathOnDisk` * `file(REAL_PATH)` * `get_filename_component(... ABSOLUTE)` Fixes: #20214 --- Source/cmFileCommand.cxx | 1 + Source/cmGetFilenameComponentCommand.cxx | 1 + Source/cmSystemTools.cxx | 3 +++ 3 files changed, 5 insertions(+) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 964debf0f6..9cb8d906f0 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1420,6 +1420,7 @@ bool HandleRealPathCommand(std::vector const& args, std::string oldPolicyPath = cmSystemTools::CollapseFullPath(input, *arguments.BaseDirectory); oldPolicyPath = cmSystemTools::GetRealPath(oldPolicyPath); + oldPolicyPath = cmSystemTools::GetActualCaseForPath(oldPolicyPath); if (warnAbout152) { computeNewPath(input, realPath); if (oldPolicyPath != realPath) { diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 1815c4d1c4..6ca5930958 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -113,6 +113,7 @@ bool cmGetFilenameComponentCommand(std::vector const& args, // Resolve symlinks if possible result = cmSystemTools::GetRealPath(result); } + result = cmSystemTools::GetActualCaseForPath(result); } else { std::string err = "unknown component " + args[2]; status.SetError(err); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 856da77fea..dcd90bcb18 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1664,6 +1664,9 @@ std::string cmSystemTools::ToNormalizedPathOnDisk(std::string p) { p = cmSystemTools::CollapseFullPath(p); cmSystemTools::ConvertToUnixSlashes(p); +#ifdef _WIN32 + p = cmSystemTools::GetActualCaseForPathCached(p); +#endif return p; }