mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 08:08:24 -05:00
Genex: Teach SHELL_PATH to support a list of paths
Extend the genex added by commit ca6ba3fee5 (Genex: Add a SHELL_PATH
expression, 2015-09-24, v3.4.0-rc1~37^2) to accept a `;`-list of paths,
convert them all, and generate a list separated by the native shell
`PATH``` separator.
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include "cmMessageType.h"
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
@@ -2045,13 +2047,27 @@ static const struct ShellPathNode : public cmGeneratorExpressionNode
|
||||
const GeneratorExpressionContent* content,
|
||||
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
|
||||
{
|
||||
if (!cmSystemTools::FileIsFullPath(parameters.front())) {
|
||||
std::vector<std::string> listIn;
|
||||
cmSystemTools::ExpandListArgument(parameters.front(), listIn);
|
||||
if (listIn.empty()) {
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"\"" + parameters.front() + "\" is not an absolute path.");
|
||||
"\"\" is not an absolute path.");
|
||||
return std::string();
|
||||
}
|
||||
cmOutputConverter converter(context->LG->GetStateSnapshot());
|
||||
return converter.ConvertDirectorySeparatorsForShell(parameters.front());
|
||||
cmStateSnapshot snapshot = context->LG->GetStateSnapshot();
|
||||
cmOutputConverter converter(snapshot);
|
||||
const char* separator = snapshot.GetState()->UseWindowsShell() ? ";" : ":";
|
||||
std::vector<std::string> listOut;
|
||||
listOut.reserve(listIn.size());
|
||||
for (auto const& in : listIn) {
|
||||
if (!cmSystemTools::FileIsFullPath(in)) {
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"\"" + in + "\" is not an absolute path.");
|
||||
return std::string();
|
||||
}
|
||||
listOut.emplace_back(converter.ConvertDirectorySeparatorsForShell(in));
|
||||
}
|
||||
return cmJoin(listOut, separator);
|
||||
}
|
||||
} shellPathNode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user