Prechádzať zdrojové kódy

cmSystemTools: Add SplitEnvPathNormalized to split paths from environment

Brad King 1 rok pred
rodič
commit
2108f3507f

+ 4 - 2
Source/cmFindPackageCommand.cxx

@@ -1961,11 +1961,13 @@ void cmFindPackageCommand::PushFindPackageRootPathStack()
     cmExpandList(*rootDEF, rootPaths);
   }
   if (rootEnv) {
-    std::vector<std::string> p = cmSystemTools::SplitEnvPath(*rootEnv);
+    std::vector<std::string> p =
+      cmSystemTools::SplitEnvPathNormalized(*rootEnv);
     std::move(p.begin(), p.end(), std::back_inserter(rootPaths));
   }
   if (rootENV) {
-    std::vector<std::string> p = cmSystemTools::SplitEnvPath(*rootENV);
+    std::vector<std::string> p =
+      cmSystemTools::SplitEnvPathNormalized(*rootENV);
     std::move(p.begin(), p.end(), std::back_inserter(rootPaths));
   }
 }

+ 9 - 3
Source/cmSystemTools.cxx

@@ -1635,9 +1635,15 @@ std::vector<std::string> 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<std::string> cmSystemTools::SplitEnvPathNormalized(
+  cm::string_view in)
+{
+  std::vector<std::string> paths = cmSystemTools::SplitEnvPath(in);
+  std::transform(paths.begin(), paths.end(), paths.begin(),
+                 cmSystemTools::ToNormalizedPathOnDisk);
   return paths;
 }
 

+ 1 - 0
Source/cmSystemTools.h

@@ -401,6 +401,7 @@ public:
   static cm::optional<std::string> GetEnvVar(std::string const& var);
 
   static std::vector<std::string> SplitEnvPath(cm::string_view in);
+  static std::vector<std::string> SplitEnvPathNormalized(cm::string_view in);
 
   static std::string ToNormalizedPathOnDisk(std::string p);