summaryrefslogtreecommitdiffstats
path: root/Source/cmAddCustomCommandCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-09-17 14:50:46 (GMT)
committerBrad King <brad.king@kitware.com>2007-09-17 14:50:46 (GMT)
commitd7a5d4c191b503f0d30abf9fbf0672370157c430 (patch)
tree225cd10e9967d49c05142e1dc8e938177114101b /Source/cmAddCustomCommandCommand.cxx
parent267fd538d837d40e7ed865326899e0105265a515 (diff)
downloadCMake-d7a5d4c191b503f0d30abf9fbf0672370157c430.zip
CMake-d7a5d4c191b503f0d30abf9fbf0672370157c430.tar.gz
CMake-d7a5d4c191b503f0d30abf9fbf0672370157c430.tar.bz2
ENH: Added IMPLICIT_DEPENDS option to ADD_CUSTOM_COMMAND. It currently works only for Makefile generators. It allows a custom command to have implicit dependencies in the form of C or CXX sources.
Diffstat (limited to 'Source/cmAddCustomCommandCommand.cxx')
-rw-r--r--Source/cmAddCustomCommandCommand.cxx52
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index a55c7e8..6bff7c1 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -40,6 +40,8 @@ bool cmAddCustomCommandCommand::InitialPass(
std::vector<std::string> depends, outputs, output;
bool verbatim = false;
bool append = false;
+ std::string implicit_depends_lang;
+ cmCustomCommand::ImplicitDependsList implicit_depends;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -54,6 +56,8 @@ bool cmAddCustomCommandCommand::InitialPass(
doing_command,
doing_target,
doing_depends,
+ doing_implicit_depends_lang,
+ doing_implicit_depends_file,
doing_main_dependency,
doing_output,
doing_outputs,
@@ -131,6 +135,10 @@ bool cmAddCustomCommandCommand::InitialPass(
{
doing = doing_main_dependency;
}
+ else if (copy == "IMPLICIT_DEPENDS")
+ {
+ doing = doing_implicit_depends_lang;
+ }
else if (copy == "COMMENT")
{
doing = doing_comment;
@@ -173,6 +181,25 @@ bool cmAddCustomCommandCommand::InitialPass(
case doing_main_dependency:
main_dependency = copy;
break;
+ case doing_implicit_depends_lang:
+ implicit_depends_lang = copy;
+ doing = doing_implicit_depends_file;
+ break;
+ case doing_implicit_depends_file:
+ {
+ // An implicit dependency starting point is also an
+ // explicit dependency.
+ depends.push_back(copy);
+
+ // Add the implicit dependency language and file.
+ cmCustomCommand::ImplicitDependsPair
+ entry(implicit_depends_lang, copy);
+ implicit_depends.push_back(entry);
+
+ // Switch back to looking for a language.
+ doing = doing_implicit_depends_lang;
+ }
+ break;
case doing_command:
currentLine.push_back(copy);
break;
@@ -240,6 +267,7 @@ bool cmAddCustomCommandCommand::InitialPass(
{
cc->AppendCommands(commandLines);
cc->AppendDepends(depends);
+ cc->AppendImplicitDepends(implicit_depends);
return true;
}
}
@@ -271,6 +299,29 @@ bool cmAddCustomCommandCommand::InitialPass(
commandLines, comment,
working.c_str(), false,
escapeOldStyle);
+
+ // Add implicit dependency scanning requests if any were given.
+ if(!implicit_depends.empty())
+ {
+ bool okay = false;
+ if(cmSourceFile* sf =
+ this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+ {
+ if(cmCustomCommand* cc = sf->GetCustomCommand())
+ {
+ okay = true;
+ cc->SetImplicitDepends(implicit_depends);
+ }
+ }
+ if(!okay)
+ {
+ cmOStringStream e;
+ e << "could not locate source file with a custom command producing \""
+ << output[0] << "\" even though this command tried to create it!";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
}
else
{
@@ -279,6 +330,7 @@ bool cmAddCustomCommandCommand::InitialPass(
source.c_str(), commandLines,
comment);
}
+
return true;
}