summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmStringCommand.cxx27
-rw-r--r--Source/cmStringCommand.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 5a6cf48..b07eae1 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) {
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 88015ad..0dded15 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -46,6 +46,7 @@ protected:
bool HandleLengthCommand(std::vector<std::string> const& args);
bool HandleSubstringCommand(std::vector<std::string> const& args);
bool HandleAppendCommand(std::vector<std::string> const& args);
+ bool HandlePrependCommand(std::vector<std::string> const& args);
bool HandleConcatCommand(std::vector<std::string> const& args);
bool HandleStripCommand(std::vector<std::string> const& args);
bool HandleRandomCommand(std::vector<std::string> const& args);