[cmake-commits] king committed cmAddCustomCommandCommand.h 1.27 1.28
cmTarget.cxx 1.143 1.144 cmTarget.h 1.83 1.84
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed May 23 13:27:02 EDT 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv10769/Source
Modified Files:
cmAddCustomCommandCommand.h cmTarget.cxx cmTarget.h
Log Message:
BUG: Target names in the COMMAND part of a custom command should not create a file-level dependency that forces the command to rerun when the executable target rebuilds, but the target-level dependency should still be created. Target names in a DEPENDS should do both a target-level and file-level dependency. Updated the BuildDepends test to check that this works.
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- cmTarget.h 22 May 2007 14:24:59 -0000 1.83
+++ cmTarget.h 23 May 2007 17:27:00 -0000 1.84
@@ -296,9 +296,10 @@
const LibraryID& dep);
/*
- * Checks the prebuild, prelink and postbuild custom commands for known
- * targets and adds them to the dependencies.
+ * Check custom commands for known targets and add a target-level
+ * dependency.
*/
+ void CheckForTargetsAsCommand(const cmCustomCommand& cc);
void CheckForTargetsAsCommand(const std::vector<cmCustomCommand>& commands);
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- cmTarget.cxx 23 May 2007 12:24:29 -0000 1.143
+++ cmTarget.cxx 23 May 2007 17:27:00 -0000 1.144
@@ -409,7 +409,29 @@
}
-void
+void cmTarget::CheckForTargetsAsCommand(const cmCustomCommand& cc)
+{
+ for(cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
+ cit != cc.GetCommandLines().end(); ++cit )
+ {
+ std::string const& command = *cit->begin();
+ // Look for a non-imported target with this name.
+ if(cmTarget* t = this->Makefile->GetLocalGenerator()->
+ GetGlobalGenerator()->FindTarget(0, command.c_str(), false))
+ {
+ if(t->GetType() == cmTarget::EXECUTABLE)
+ {
+ // The command refers to an executable target built in
+ // this project. Add the target-level dependency to make
+ // sure the executable is up to date before this custom
+ // command possibly runs.
+ this->AddUtility(command.c_str());
+ }
+ }
+ }
+}
+
+void
cmTarget
::CheckForTargetsAsCommand(const std::vector<cmCustomCommand>& commands)
{
@@ -417,20 +439,7 @@
cli != commands.end();
++cli )
{
- for(cmCustomCommandLines::const_iterator cit =
- cli->GetCommandLines().begin();
- cit!=cli->GetCommandLines().end();
- ++cit )
- {
- std::string command = *cit->begin();
- // see if we can find a target with this name
- cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, command.c_str(), false);
- if ( ( t ) && ( t->GetType() ==cmTarget::EXECUTABLE ) )
- {
- this->AddUtility ( command.c_str() );
- }
- }
+ this->CheckForTargetsAsCommand(*cli);
}
}
@@ -566,24 +575,8 @@
}
}
- // check if commands for this custom commands are names of targets and
- // if that's the case add these targets as dependencies
- std::vector<std::string> automaticTargetDepends;
- for(cmCustomCommandLines::const_iterator it=
- outsf->GetCustomCommand()->GetCommandLines().begin();
- it!=outsf->GetCustomCommand()->GetCommandLines().end();
- ++it)
- {
- const std::string& currentCommand = (*it)[0];
- // see if we can find a target with this name
- cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, currentCommand.c_str(), false);
- if (( t) && (t->GetType()==cmTarget::EXECUTABLE))
- {
- automaticTargetDepends.push_back(currentCommand);
- }
- }
- outsf->GetCustomCommand()->AppendDepends(automaticTargetDepends);
+ // Add target-level dependencies for the commands.
+ this->CheckForTargetsAsCommand(*outsf->GetCustomCommand());
// add its dependencies to the list to check
for (unsigned int i = 0;
@@ -598,10 +591,9 @@
dep = cmSystemTools::GetFilenameWithoutLastExtension(dep);
}
bool isUtility = false;
- // see if we can find a target with this name
- cmTarget* t = this->Makefile->GetLocalGenerator()->
- GetGlobalGenerator()->FindTarget(0, dep.c_str(), false);
- if(t)
+ // Check for a non-imported target with this name.
+ if(cmTarget* t = this->Makefile->GetLocalGenerator()->
+ GetGlobalGenerator()->FindTarget(0, dep.c_str(), false))
{
// if we find the target and the dep was given as a full
// path, then make sure it was not a full path to something
@@ -629,7 +621,9 @@
}
if(isUtility)
{
- // add the depend as a utility on the target
+ // The dependency refers to a target built in this project.
+ // Add the target-level dependency to make sure the target
+ // is up to date before this custom command possibly runs.
this->AddUtility(dep.c_str());
}
else
Index: cmAddCustomCommandCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmAddCustomCommandCommand.h 4 Oct 2006 22:09:43 -0000 1.27
+++ cmAddCustomCommandCommand.h 23 May 2007 17:27:00 -0000 1.28
@@ -124,7 +124,23 @@
"it is an option is to preserve compatibility with older CMake code.\n"
"If the output of the custom command is not actually "
"created as a file on disk it should be marked as SYMBOLIC with "
- "SET_SOURCE_FILES_PROPERTIES.";
+ "SET_SOURCE_FILES_PROPERTIES.\n"
+
+ "If COMMAND specifies an executable target (created by "
+ "ADD_EXECUTABLE) it will automatically be replaced by the location "
+ "of the executable created at build time. Additionally a "
+ "target-level dependency will be added so that the executable target "
+ "will be built before any target using this custom command. However "
+ "this does NOT add a file-level dependency that would cause the "
+ "custom command to re-run whenever the executable is recompiled.\n"
+
+ "If DEPENDS specifies any target (created by an ADD_* command) "
+ "a target-level dependency is created to make sure the target is "
+ "built before any target using this custom command. Additionally, "
+ "if the target is an executable or library a file-level dependency "
+ "is created to cause the custom command to re-run whenever the target "
+ "is recompiled.\n"
+ ;
}
cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
More information about the Cmake-commits
mailing list