summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@sap.com>2018-03-19 14:06:52 (GMT)
committerMarc Chevrier <marc.chevrier@sap.com>2018-03-20 13:28:17 (GMT)
commita58158727be4585f9fd71449e9cc9e801c59a009 (patch)
tree833d347cc669950b33e7afbc57a31be63ad3d405 /Source
parentd8826406aa343580fb4436058c205581da377d37 (diff)
downloadCMake-a58158727be4585f9fd71449e9cc9e801c59a009.zip
CMake-a58158727be4585f9fd71449e9cc9e801c59a009.tar.gz
CMake-a58158727be4585f9fd71449e9cc9e801c59a009.tar.bz2
list(): add `JOIN` sub-command
Diffstat (limited to 'Source')
-rw-r--r--Source/cmListCommand.cxx31
-rw-r--r--Source/cmListCommand.h1
2 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index ae4f0a8..62d4ea7 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -42,6 +42,9 @@ bool cmListCommand::InitialPass(std::vector<std::string> const& args,
if (subCommand == "INSERT") {
return this->HandleInsertCommand(args);
}
+ if (subCommand == "JOIN") {
+ return this->HandleJoinCommand(args);
+ }
if (subCommand == "REMOVE_AT") {
return this->HandleRemoveAtCommand(args);
}
@@ -294,6 +297,34 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
return true;
}
+bool cmListCommand::HandleJoinCommand(std::vector<std::string> const& args)
+{
+ if (args.size() != 4) {
+ std::ostringstream error;
+ error << "sub-command JOIN requires three arguments (" << args.size() - 1
+ << " found).";
+ this->SetError(error.str());
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ const std::string& glue = args[2];
+ const std::string& variableName = args[3];
+
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if (!this->GetList(varArgsExpanded, listName)) {
+ this->Makefile->AddDefinition(variableName, "");
+ return true;
+ }
+
+ std::string value =
+ cmJoin(cmMakeRange(varArgsExpanded.begin(), varArgsExpanded.end()), glue);
+
+ this->Makefile->AddDefinition(variableName, value.c_str());
+ return true;
+}
+
bool cmListCommand::HandleRemoveItemCommand(
std::vector<std::string> const& args)
{
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 2965399..d6870e6 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -37,6 +37,7 @@ protected:
bool HandleAppendCommand(std::vector<std::string> const& args);
bool HandleFindCommand(std::vector<std::string> const& args);
bool HandleInsertCommand(std::vector<std::string> const& args);
+ bool HandleJoinCommand(std::vector<std::string> const& args);
bool HandleRemoveAtCommand(std::vector<std::string> const& args);
bool HandleRemoveItemCommand(std::vector<std::string> const& args);
bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args);