mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
cmSystemTools: Add GetEnvPathNormalized to get paths from environment
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <cm/optional>
|
||||
#include <cmext/algorithm>
|
||||
#include <cmext/string_view>
|
||||
@@ -1614,6 +1616,17 @@ cm::optional<std::string> cmSystemTools::GetEnvVar(std::string const& var)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> cmSystemTools::GetEnvPathNormalized(
|
||||
std::string const& var)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
if (cm::optional<std::string> env = cmSystemTools::GetEnvVar(var)) {
|
||||
std::vector<std::string> p = cmSystemTools::SplitEnvPathNormalized(*env);
|
||||
std::move(p.begin(), p.end(), std::back_inserter(result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> cmSystemTools::SplitEnvPath(cm::string_view in)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
|
||||
@@ -399,6 +399,7 @@ public:
|
||||
std::string const& in);
|
||||
|
||||
static cm::optional<std::string> GetEnvVar(std::string const& var);
|
||||
static std::vector<std::string> GetEnvPathNormalized(std::string const& var);
|
||||
|
||||
static std::vector<std::string> SplitEnvPath(cm::string_view in);
|
||||
static std::vector<std::string> SplitEnvPathNormalized(cm::string_view in);
|
||||
|
||||
Reference in New Issue
Block a user