[cmake-commits] king committed cmGlobalGenerator.cxx 1.213 1.214
cmGlobalGenerator.h 1.99 1.100
cmGlobalUnixMakefileGenerator3.cxx 1.117 1.118
cmGlobalUnixMakefileGenerator3.h 1.49 1.50
cmLocalUnixMakefileGenerator3.cxx 1.224 1.225
cmLocalUnixMakefileGenerator3.h 1.78 1.79
cmMakefileExecutableTargetGenerator.cxx 1.37 1.38
cmMakefileLibraryTargetGenerator.cxx 1.48 1.49
cmMakefileTargetGenerator.cxx 1.77 1.78
cmMakefileTargetGenerator.h 1.16 1.17
cmMakefileUtilityTargetGenerator.cxx 1.6 1.7 cmake.cxx 1.345 1.346
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Dec 21 12:22:14 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv21743/Source
Modified Files:
cmGlobalGenerator.cxx cmGlobalGenerator.h
cmGlobalUnixMakefileGenerator3.cxx
cmGlobalUnixMakefileGenerator3.h
cmLocalUnixMakefileGenerator3.cxx
cmLocalUnixMakefileGenerator3.h
cmMakefileExecutableTargetGenerator.cxx
cmMakefileLibraryTargetGenerator.cxx
cmMakefileTargetGenerator.cxx cmMakefileTargetGenerator.h
cmMakefileUtilityTargetGenerator.cxx cmake.cxx
Log Message:
ENH: Add a depends check step to custom targets. Add support for the IMPLICIT_DEPENDS feature of custom commands when building in custom targets. Convert multiple-output pair checks to be per-target instead of global.
Index: cmLocalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- cmLocalUnixMakefileGenerator3.h 19 Dec 2007 22:15:41 -0000 1.78
+++ cmLocalUnixMakefileGenerator3.h 21 Dec 2007 17:22:12 -0000 1.79
@@ -203,9 +203,6 @@
virtual bool UpdateDependencies(const char* tgtInfo,
bool verbose, bool color);
- /** Called from command-line hook to scan dependencies. */
- bool ScanDependencies(const char* tgtInfo);
-
/** Called from command-line hook to clear dependencies. */
virtual void ClearDependencies(cmMakefile* mf, bool verbose);
@@ -325,6 +322,10 @@
std::map<cmStdString, std::vector<int> > ProgressFiles;
+ // Helper methods for dependeny updates.
+ bool ScanDependencies(const char* targetDir);
+ void CheckMultipleOutputs(bool verbose);
+
private:
friend class cmMakefileTargetGenerator;
friend class cmMakefileExecutableTargetGenerator;
Index: cmMakefileUtilityTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileUtilityTargetGenerator.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmMakefileUtilityTargetGenerator.cxx 1 May 2007 17:51:25 -0000 1.6
+++ cmMakefileUtilityTargetGenerator.cxx 21 Dec 2007 17:22:12 -0000 1.7
@@ -89,6 +89,10 @@
// Write clean target
this->WriteTargetCleanRules();
+ // Write the dependency generation rule. This must be done last so
+ // that multiple output pair information is available.
+ this->WriteTargetDependRules();
+
// close the streams
this->CloseFileStreams();
}
Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- cmGlobalGenerator.h 25 Nov 2007 12:34:53 -0000 1.99
+++ cmGlobalGenerator.h 21 Dec 2007 17:22:12 -0000 1.100
@@ -211,9 +211,6 @@
void AddTarget(cmTargets::value_type &v);
- /** Support for multiple custom command outputs. */
- virtual void CheckMultipleOutputs(cmMakefile* mf, bool verbose);
-
virtual const char* GetAllTargetName() { return "ALL_BUILD"; }
virtual const char* GetInstallTargetName() { return "INSTALL"; }
virtual const char* GetInstallLocalTargetName() { return 0; }
Index: cmGlobalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.cxx,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- cmGlobalUnixMakefileGenerator3.cxx 13 Dec 2007 20:54:29 -0000 1.117
+++ cmGlobalUnixMakefileGenerator3.cxx 21 Dec 2007 17:22:12 -0000 1.118
@@ -133,16 +133,6 @@
}
//----------------------------------------------------------------------------
-void
-cmGlobalUnixMakefileGenerator3
-::AddMultipleOutputPair(const char* depender, const char* dependee)
-{
- MultipleOutputPairsType::value_type p(depender, dependee);
- this->MultipleOutputPairs.insert(p);
-}
-
-
-//----------------------------------------------------------------------------
void cmGlobalUnixMakefileGenerator3::Generate()
{
// first do superclass method
@@ -373,62 +363,6 @@
this->WriteMainCMakefileLanguageRules(cmakefileStream,
this->LocalGenerators);
-
- if(!this->MultipleOutputPairs.empty())
- {
- cmakefileStream
- << "\n"
- << "SET(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
- for(MultipleOutputPairsType::const_iterator pi =
- this->MultipleOutputPairs.begin();
- pi != this->MultipleOutputPairs.end(); ++pi)
- {
- cmakefileStream << " \"" << pi->first << "\" \""
- << pi->second << "\"\n";
- }
- cmakefileStream << " )\n\n";
- }
-}
-
-//----------------------------------------------------------------------------
-void cmGlobalUnixMakefileGenerator3::CheckMultipleOutputs(cmMakefile* mf,
- bool verbose)
-{
- // Get the string listing the multiple output pairs.
- const char* pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS");
- if(!pairs_string)
- {
- return;
- }
-
- // Convert the string to a list and preserve empty entries.
- std::vector<std::string> pairs;
- cmSystemTools::ExpandListArgument(pairs_string, pairs, true);
- for(std::vector<std::string>::const_iterator i = pairs.begin();
- i != pairs.end(); ++i)
- {
- const std::string& depender = *i;
- if(++i != pairs.end())
- {
- const std::string& dependee = *i;
-
- // If the depender is missing then delete the dependee to make
- // sure both will be regenerated.
- if(cmSystemTools::FileExists(dependee.c_str()) &&
- !cmSystemTools::FileExists(depender.c_str()))
- {
- if(verbose)
- {
- cmOStringStream msg;
- msg << "Deleting primary custom command output \"" << dependee
- << "\" because another output \""
- << depender << "\" does not exist." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
- }
- cmSystemTools::RemoveFile(dependee.c_str());
- }
- }
- }
}
void cmGlobalUnixMakefileGenerator3
@@ -763,21 +697,18 @@
<< localName << "\n\n";
commands.clear();
- if (t->second.GetType() != cmTarget::UTILITY)
+ makeTargetName = localName;
+ makeTargetName += "/depend";
+ commands.push_back(lg->GetRecursiveMakeCall
+ (makefileName.c_str(),makeTargetName.c_str()));
+
+ // add requires if we need it for this generator
+ if (needRequiresStep)
{
makeTargetName = localName;
- makeTargetName += "/depend";
+ makeTargetName += "/requires";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
-
- // add requires if we need it for this generator
- if (needRequiresStep)
- {
- makeTargetName = localName;
- makeTargetName += "/requires";
- commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
- }
+ (makefileName.c_str(),makeTargetName.c_str()));
}
makeTargetName = localName;
makeTargetName += "/build";
Index: cmGlobalUnixMakefileGenerator3.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalUnixMakefileGenerator3.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- cmGlobalUnixMakefileGenerator3.h 25 Nov 2007 12:34:53 -0000 1.49
+++ cmGlobalUnixMakefileGenerator3.h 21 Dec 2007 17:22:12 -0000 1.50
@@ -98,19 +98,6 @@
void WriteConvenienceRules(std::ostream& ruleFileStream,
std::set<cmStdString> &emitted);
- /** In order to support parallel builds for custom commands with
- multiple outputs the outputs are given a serial order, and only
- the first output actually has the build rule. Other outputs
- just depend on the first one. The check-build-system step must
- remove a dependee if the depender is missing to make sure both
- are regenerated properly. This method is used by the local
- makefile generators to register such pairs. */
- void AddMultipleOutputPair(const char* depender, const char* dependee);
-
- /** Support for multiple custom command outputs. Called during
- check-build-system step. */
- virtual void CheckMultipleOutputs(cmMakefile* mf, bool verbose);
-
/** Get the command to use for a target that has no rule. This is
used for multiple output dependencies and for cmake_force. */
std::string GetEmptyRuleHackCommand() { return this->EmptyRuleHackCommand; }
@@ -191,9 +178,6 @@
// in the rule to satisfy the make program.
std::string EmptyRuleHackCommand;
- typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
- MultipleOutputPairsType MultipleOutputPairs;
-
std::map<cmStdString, int > TargetSourceFileCount;
bool ForceVerboseMakefiles;
};
Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -d -r1.213 -r1.214
--- cmGlobalGenerator.cxx 20 Nov 2007 16:10:11 -0000 1.213
+++ cmGlobalGenerator.cxx 21 Dec 2007 17:22:12 -0000 1.214
@@ -1681,13 +1681,6 @@
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::CheckMultipleOutputs(cmMakefile*, bool)
-{
- // Only certain generators need this check. They define this
- // method.
-}
-
-//----------------------------------------------------------------------------
std::vector<cmTarget *>& cmGlobalGenerator
::GetTargetDepends(cmTarget& target)
{
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.345
retrieving revision 1.346
diff -u -d -r1.345 -r1.346
--- cmake.cxx 19 Dec 2007 22:15:41 -0000 1.345
+++ cmake.cxx 21 Dec 2007 17:22:12 -0000 1.346
@@ -2547,29 +2547,24 @@
return 1;
}
- // Now that we know the generator used to build the project, use it
- // to check the dependency integrity.
- const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
- if (!genName || genName[0] == '\0')
- {
- genName = "Unix Makefiles";
- }
- // this global generator is never set to the cmake object so it is never
- // deleted, so make it an auto_ptr
- std::auto_ptr<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName));
- if (ggd.get())
+ if(this->ClearBuildSystem)
{
- // Check the dependencies in case source files were removed.
- std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
- lgd->SetGlobalGenerator(ggd.get());
+ // Get the generator used for this build system.
+ const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
+ if(!genName || genName[0] == '\0')
+ {
+ genName = "Unix Makefiles";
+ }
- if(this->ClearBuildSystem)
+ // Create the generator and use it to clear the dependencies.
+ std::auto_ptr<cmGlobalGenerator>
+ ggd(this->CreateGlobalGenerator(genName));
+ if(ggd.get())
{
+ std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
+ lgd->SetGlobalGenerator(ggd.get());
lgd->ClearDependencies(mf, verbose);
}
-
- // Check for multiple output pairs.
- ggd->CheckMultipleOutputs(mf, verbose);
}
// Get the set of dependencies and outputs.
Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- cmMakefileLibraryTargetGenerator.cxx 18 Oct 2007 13:38:34 -0000 1.48
+++ cmMakefileLibraryTargetGenerator.cxx 21 Dec 2007 17:22:12 -0000 1.49
@@ -47,9 +47,6 @@
// write the per-target per-language flags
this->WriteTargetLanguageFlags();
- // Write the dependency generation rule.
- this->WriteTargetDependRules();
-
// write the link rules
// Write the rule for this target type.
switch(this->Target->GetType())
@@ -85,6 +82,10 @@
// Write clean target
this->WriteTargetCleanRules();
+ // Write the dependency generation rule. This must be done last so
+ // that multiple output pair information is available.
+ this->WriteTargetDependRules();
+
// close the streams
this->CloseFileStreams();
}
Index: cmMakefileTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cmMakefileTargetGenerator.h 11 Jun 2007 16:40:41 -0000 1.16
+++ cmMakefileTargetGenerator.h 21 Dec 2007 17:22:12 -0000 1.17
@@ -119,6 +119,15 @@
// append intertarget dependencies
void AppendTargetDepends(std::vector<std::string>& depends);
+ /** In order to support parallel builds for custom commands with
+ multiple outputs the outputs are given a serial order, and only
+ the first output actually has the build rule. Other outputs
+ just depend on the first one. The check-build-system step must
+ remove a dependee if the depender is missing to make sure both
+ are regenerated properly. This method is used by the local
+ makefile generators to register such pairs. */
+ void AddMultipleOutputPair(const char* depender, const char* dependee);
+
virtual void CloseFileStreams();
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
std::string& linkFlags);
@@ -166,6 +175,8 @@
// Set of object file names that will be built in this directory.
std::set<cmStdString> ObjectFiles;
+ typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
+ MultipleOutputPairsType MultipleOutputPairs;
//==================================================================
// Convenience routines that do nothing more than forward to
Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cmMakefileExecutableTargetGenerator.cxx 18 Oct 2007 13:38:34 -0000 1.37
+++ cmMakefileExecutableTargetGenerator.cxx 21 Dec 2007 17:22:12 -0000 1.38
@@ -45,9 +45,6 @@
// write the per-target per-language flags
this->WriteTargetLanguageFlags();
- // Write the dependency generation rule.
- this->WriteTargetDependRules();
-
// write the link rules
this->WriteExecutableRule(false);
if(this->Target->NeedRelinkBeforeInstall())
@@ -62,6 +59,10 @@
// Write clean target
this->WriteTargetCleanRules();
+ // Write the dependency generation rule. This must be done last so
+ // that multiple output pair information is available.
+ this->WriteTargetDependRules();
+
// close the streams
this->CloseFileStreams();
}
Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -d -r1.224 -r1.225
--- cmLocalUnixMakefileGenerator3.cxx 19 Dec 2007 22:54:24 -0000 1.224
+++ cmLocalUnixMakefileGenerator3.cxx 21 Dec 2007 17:22:12 -0000 1.225
@@ -1229,6 +1229,16 @@
bool verbose,
bool color)
{
+ // read in the target info file
+ if(!this->Makefile->ReadListFile(0, tgtInfo) ||
+ cmSystemTools::GetErrorOccuredFlag())
+ {
+ cmSystemTools::Error("Target DependInfo.cmake file not found");
+ }
+
+ // Check if any multiple output pairs have a missing file.
+ this->CheckMultipleOutputs(verbose);
+
std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
std::string internalDependFile = dir + "/depend.internal";
std::string dependFile = dir + "/depend.make";
@@ -1257,7 +1267,7 @@
fprintf(stdout, "%s\n", message.c_str());
#endif
- return this->ScanDependencies(tgtInfo);
+ return this->ScanDependencies(dir.c_str());
}
else
{
@@ -1267,11 +1277,10 @@
}
//----------------------------------------------------------------------------
-bool cmLocalUnixMakefileGenerator3::ScanDependencies(const char* tgtInfo)
+bool
+cmLocalUnixMakefileGenerator3
+::ScanDependencies(const char* targetDir)
{
- // The info file for this target
- std::string infoFile = tgtInfo;
-
// Read the directory information file.
cmMakefile* mf = this->Makefile;
bool haveDirectoryInfo = false;
@@ -1284,13 +1293,6 @@
haveDirectoryInfo = true;
}
- // read in the target info file
- if(!mf->ReadListFile(0, infoFile.c_str()) ||
- cmSystemTools::GetErrorOccuredFlag())
- {
- cmSystemTools::Error("Target DependInfo.cmake file not found");
- }
-
// Lookup useful directory information.
if(haveDirectoryInfo)
{
@@ -1322,7 +1324,7 @@
}
// create the file stream for the depends file
- std::string dir = cmSystemTools::GetFilenamePath(infoFile);
+ std::string dir = targetDir;
// Open the rule file. This should be copy-if-different because the
// rules may depend on this file itself.
@@ -1450,6 +1452,48 @@
}
//----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
+{
+ cmMakefile* mf = this->Makefile;
+
+ // Get the string listing the multiple output pairs.
+ const char* pairs_string = mf->GetDefinition("CMAKE_MULTIPLE_OUTPUT_PAIRS");
+ if(!pairs_string)
+ {
+ return;
+ }
+
+ // Convert the string to a list and preserve empty entries.
+ std::vector<std::string> pairs;
+ cmSystemTools::ExpandListArgument(pairs_string, pairs, true);
+ for(std::vector<std::string>::const_iterator i = pairs.begin();
+ i != pairs.end(); ++i)
+ {
+ const std::string& depender = *i;
+ if(++i != pairs.end())
+ {
+ const std::string& dependee = *i;
+
+ // If the depender is missing then delete the dependee to make
+ // sure both will be regenerated.
+ if(cmSystemTools::FileExists(dependee.c_str()) &&
+ !cmSystemTools::FileExists(depender.c_str()))
+ {
+ if(verbose)
+ {
+ cmOStringStream msg;
+ msg << "Deleting primary custom command output \"" << dependee
+ << "\" because another output \""
+ << depender << "\" does not exist." << std::endl;
+ cmSystemTools::Stdout(msg.str().c_str());
+ }
+ cmSystemTools::RemoveFile(dependee.c_str());
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3
::WriteLocalAllRules(std::ostream& ruleFileStream)
{
Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- cmMakefileTargetGenerator.cxx 21 Dec 2007 16:00:03 -0000 1.77
+++ cmMakefileTargetGenerator.cxx 21 Dec 2007 17:22:12 -0000 1.78
@@ -775,6 +775,23 @@
this->LocalGenerator->
WriteDependLanguageInfo(*this->InfoFileStream,*this->Target);
+ // Store multiple output pairs in the depend info file.
+ if(!this->MultipleOutputPairs.empty())
+ {
+ *this->InfoFileStream
+ << "\n"
+ << "# Pairs of files generated by the same build rule.\n"
+ << "SET(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
+ for(MultipleOutputPairsType::const_iterator pi =
+ this->MultipleOutputPairs.begin();
+ pi != this->MultipleOutputPairs.end(); ++pi)
+ {
+ *this->InfoFileStream << " \"" << pi->first << "\" \""
+ << pi->second << "\"\n";
+ }
+ *this->InfoFileStream << " )\n\n";
+ }
+
// and now write the rule to use it
std::vector<std::string> depends;
std::vector<std::string> commands;
@@ -993,7 +1010,7 @@
// the check-build-system step will remove the primary output if any
// extra outputs are missing. This forces the rule to regenerate
// all outputs.
- this->GlobalGenerator->AddMultipleOutputPair(out, in);
+ this->AddMultipleOutputPair(out, in);
}
//----------------------------------------------------------------------------
@@ -1334,3 +1351,12 @@
current += this->NumberOfProgressActions;
delete progressFileStream;
}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
+::AddMultipleOutputPair(const char* depender, const char* dependee)
+{
+ MultipleOutputPairsType::value_type p(depender, dependee);
+ this->MultipleOutputPairs.insert(p);
+}
More information about the Cmake-commits
mailing list