diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 7535ffc633..03b95eab07 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1961,11 +1961,13 @@ void cmFindPackageCommand::PushFindPackageRootPathStack() cmExpandList(*rootDEF, rootPaths); } if (rootEnv) { - std::vector p = cmSystemTools::SplitEnvPath(*rootEnv); + std::vector p = + cmSystemTools::SplitEnvPathNormalized(*rootEnv); std::move(p.begin(), p.end(), std::back_inserter(rootPaths)); } if (rootENV) { - std::vector p = cmSystemTools::SplitEnvPath(*rootENV); + std::vector p = + cmSystemTools::SplitEnvPathNormalized(*rootENV); std::move(p.begin(), p.end(), std::back_inserter(rootPaths)); } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 1c73d5ae24..f355731e6e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1635,9 +1635,15 @@ std::vector cmSystemTools::SplitEnvPath(cm::string_view in) } paths.emplace_back(in.substr(b, e - b)); } - for (std::string& p : paths) { - SystemTools::ConvertToUnixSlashes(p); - } + return paths; +} + +std::vector cmSystemTools::SplitEnvPathNormalized( + cm::string_view in) +{ + std::vector paths = cmSystemTools::SplitEnvPath(in); + std::transform(paths.begin(), paths.end(), paths.begin(), + cmSystemTools::ToNormalizedPathOnDisk); return paths; } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index dab96f0638..c4bd124317 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -401,6 +401,7 @@ public: static cm::optional GetEnvVar(std::string const& var); static std::vector SplitEnvPath(cm::string_view in); + static std::vector SplitEnvPathNormalized(cm::string_view in); static std::string ToNormalizedPathOnDisk(std::string p);