summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-20 13:39:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-03-20 13:40:40 (GMT)
commitd41abae70f282c718f3109b7f76644adce41ff37 (patch)
treea1e04513a8df7dc1befba5878d1c6d341abe6581 /Source
parent3b99c9689aae478708c83cafa552c4ce7bbf4a1b (diff)
parenta58158727be4585f9fd71449e9cc9e801c59a009 (diff)
downloadCMake-d41abae70f282c718f3109b7f76644adce41ff37.zip
CMake-d41abae70f282c718f3109b7f76644adce41ff37.tar.gz
CMake-d41abae70f282c718f3109b7f76644adce41ff37.tar.bz2
Merge topic 'list-join'
a58158727b list(): add `JOIN` sub-command Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1846
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);