From fc5584f9bb1dbc84eca46291fd721dba1149e02f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 7 Mar 2025 15:07:20 -0500 Subject: [PATCH] cmSystemTools: Fix regression in input path normalization on Windows Since commit 622596c6b2 (cmSystemTools: Re-implement ToNormalizedPathOnDisk without translation map, 2024-10-30, v4.0.0-rc1~528^2~5) we normalize input paths, while resolving symlinks only if followed by `..` components, by using `cm::PathResolver`'s `LogicalPath` mode. However, that approach assumes POSIX semantics for resolving paths with symlinks and is incorrect on Windows. On Windows, file system operations naively remove any component preceding `..` regardless of whether it is a symlink. Prior to the above commit, `ToNormalizedPathOnDisk` matched that behavior using `CollapseFullPath` followed by `GetActualCaseForPath`. Restore it using `cm::PathResolver`'s `CasePath` mode. Issue: #26750 --- Source/cmSystemTools.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7d2ac65d88..21f285c2e5 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1991,8 +1991,13 @@ std::vector cmSystemTools::SplitEnvPathNormalized( std::string cmSystemTools::ToNormalizedPathOnDisk(std::string p) { using namespace cm::PathResolver; +#ifdef _WIN32 + // IWYU pragma: no_forward_declare cm::PathResolver::Policies::CasePath + static Resolver const resolver(RealOS); +#else // IWYU pragma: no_forward_declare cm::PathResolver::Policies::LogicalPath static Resolver const resolver(RealOS); +#endif resolver.Resolve(std::move(p), p); return p; }