summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomCommandCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-10-04 19:24:26 (GMT)
committerBrad King <brad.king@kitware.com>2006-10-04 19:24:26 (GMT)
commit2dfa2ba888bb3f1ea5dd5eedf84a3c5b23bdb202 (patch)
tree91630ef8018256a23451bbdba07436c2374732ea /Source/cmAddCustomCommandCommand.cxx
parent523075ded543cbb7044bc4b56203d329aff0cb42 (diff)
downloadCMake-2dfa2ba888bb3f1ea5dd5eedf84a3c5b23bdb202.zip
CMake-2dfa2ba888bb3f1ea5dd5eedf84a3c5b23bdb202.tar.gz
CMake-2dfa2ba888bb3f1ea5dd5eedf84a3c5b23bdb202.tar.bz2
ENH: Added APPEND option to ADD_CUSTOM_COMMAND to allow extra dependencies to be connected later. This is useful to create one rule and then have a macro add things to it later. This addresses bug#2151.
Diffstat (limited to 'Source/cmAddCustomCommandCommand.cxx')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 3f0dd26..a55c7e8 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -18,6 +18,8 @@
#include "cmTarget.h"
+#include "cmSourceFile.h"
+
// cmAddCustomCommandCommand
bool cmAddCustomCommandCommand::InitialPass(
std::vector<std::string> const& args)
@@ -37,6 +39,7 @@ bool cmAddCustomCommandCommand::InitialPass(
const char* comment = 0;
std::vector<std::string> depends, outputs, output;
bool verbatim = false;
+ bool append = false;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -96,6 +99,10 @@ bool cmAddCustomCommandCommand::InitialPass(
{
verbatim = true;
}
+ else if(copy == "APPEND")
+ {
+ append = true;
+ }
else if(copy == "TARGET")
{
doing = doing_target;
@@ -210,6 +217,11 @@ bool cmAddCustomCommandCommand::InitialPass(
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
return false;
}
+ if(append && output.empty())
+ {
+ this->SetError("given APPEND option with no OUTPUT.");
+ return false;
+ }
// Make sure the output names and locations are safe.
if(!this->CheckOutputs(output) || !this->CheckOutputs(outputs))
@@ -217,6 +229,29 @@ bool cmAddCustomCommandCommand::InitialPass(
return false;
}
+ // Check for an append request.
+ if(append)
+ {
+ // Lookup an existing command.
+ if(cmSourceFile* sf =
+ this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+ {
+ if(cmCustomCommand* cc = sf->GetCustomCommand())
+ {
+ cc->AppendCommands(commandLines);
+ cc->AppendDepends(depends);
+ return true;
+ }
+ }
+
+ // No command for this output exists.
+ cmOStringStream e;
+ e << "given APPEND option with output \"" << output[0].c_str()
+ << "\" which is not already a custom command output.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
// Choose which mode of the command to use.
bool escapeOldStyle = !verbatim;
if(source.empty() && output.empty())