diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-03-19 14:06:52 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@sap.com> | 2018-03-20 13:28:17 (GMT) |
commit | a58158727be4585f9fd71449e9cc9e801c59a009 (patch) | |
tree | 833d347cc669950b33e7afbc57a31be63ad3d405 /Source/cmListCommand.cxx | |
parent | d8826406aa343580fb4436058c205581da377d37 (diff) | |
download | CMake-a58158727be4585f9fd71449e9cc9e801c59a009.zip CMake-a58158727be4585f9fd71449e9cc9e801c59a009.tar.gz CMake-a58158727be4585f9fd71449e9cc9e801c59a009.tar.bz2 |
list(): add `JOIN` sub-command
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r-- | Source/cmListCommand.cxx | 31 |
1 files changed, 31 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) { |