summaryrefslogtreecommitdiff
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorSylvain Joubert <joubert.sy@gmail.com>2017-08-11 13:26:33 +0200
committerSylvain Joubert <joubert.sy@gmail.com>2017-08-11 13:26:33 +0200
commitd8ecc2545798c77ec5bf22bb420a3343d4843ef6 (patch)
treede0ac663a00cb494ec78452811ca1f0aac3f551d /Source/cmStringCommand.cxx
parentf8a61c578badb0015423580b38341bc00a3c7fd4 (diff)
downloadcmake-d8ecc2545798c77ec5bf22bb420a3343d4843ef6.tar.gz
Add PREPEND sub-command to string command
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 5a6cf481f6..b07eae174b 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -62,6 +62,9 @@ bool cmStringCommand::InitialPass(std::vector<std::string> const& args,
if (subCommand == "APPEND") {
return this->HandleAppendCommand(args);
}
+ if (subCommand == "PREPEND") {
+ return this->HandlePrependCommand(args);
+ }
if (subCommand == "CONCAT") {
return this->HandleConcatCommand(args);
}
@@ -643,6 +646,30 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
return true;
}
+bool cmStringCommand::HandlePrependCommand(
+ std::vector<std::string> const& args)
+{
+ if (args.size() < 2) {
+ this->SetError("sub-command PREPEND requires at least one argument.");
+ return false;
+ }
+
+ // Skip if nothing to prepend.
+ if (args.size() < 3) {
+ return true;
+ }
+
+ const std::string& variable = args[1];
+
+ std::string value = cmJoin(cmMakeRange(args).advance(2), std::string());
+ const char* oldValue = this->Makefile->GetDefinition(variable);
+ if (oldValue) {
+ value += oldValue;
+ }
+ this->Makefile->AddDefinition(variable, value.c_str());
+ return true;
+}
+
bool cmStringCommand::HandleConcatCommand(std::vector<std::string> const& args)
{
if (args.size() < 2) {