summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-07-08 13:21:52 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-07-08 13:21:52 (GMT)
commitc66d232c9c138dcf54f5314aafb7ab32590b106d (patch)
treef62c5afa282b5e94fc5844f5d869e641078bae13 /Source/cmStringCommand.cxx
parent0d457c319934e6f321b838ea58ad4365e41f6f0b (diff)
parent2b18cdcaba48ffeee753d97d8241dbf2a8333493 (diff)
downloadCMake-c66d232c9c138dcf54f5314aafb7ab32590b106d.zip
CMake-c66d232c9c138dcf54f5314aafb7ab32590b106d.tar.gz
CMake-c66d232c9c138dcf54f5314aafb7ab32590b106d.tar.bz2
Merge topic 'string-append'
2b18cdca string: add APPEND subcommand
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index edc6afc..efc1f16 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -74,6 +74,10 @@ bool cmStringCommand
{
return this->HandleLengthCommand(args);
}
+ else if(subCommand == "APPEND")
+ {
+ return this->HandleAppendCommand(args);
+ }
else if(subCommand == "CONCAT")
{
return this->HandleConcatCommand(args);
@@ -730,6 +734,34 @@ bool cmStringCommand
}
//----------------------------------------------------------------------------
+bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
+{
+ if(args.size() < 2)
+ {
+ this->SetError("sub-command APPEND requires at least one argument.");
+ return false;
+ }
+
+ // Skip if nothing to append.
+ if(args.size() < 3)
+ {
+ return true;
+ }
+
+ const std::string& variable = args[1];
+
+ std::string value;
+ const char* oldValue = this->Makefile->GetDefinition(variable);
+ if(oldValue)
+ {
+ value = oldValue;
+ }
+ value += cmJoin(cmRange(args).advance(2), std::string());
+ this->Makefile->AddDefinition(variable, value.c_str());
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmStringCommand
::HandleConcatCommand(std::vector<std::string> const& args)
{