summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalUnixMakefileGenerator3.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-12-21 17:22:12 (GMT)
committerBrad King <brad.king@kitware.com>2007-12-21 17:22:12 (GMT)
commitd83b4cd255bcd13b5b7e4279a6e3e959fcb58688 (patch)
tree1987a83567e98da043994e7fa870fe48c7b08c8a /Source/cmLocalUnixMakefileGenerator3.cxx
parent6586149d64be27694652b40bfbcc4d19f6c2c5eb (diff)
downloadCMake-d83b4cd255bcd13b5b7e4279a6e3e959fcb58688.zip
CMake-d83b4cd255bcd13b5b7e4279a6e3e959fcb58688.tar.gz
CMake-d83b4cd255bcd13b5b7e4279a6e3e959fcb58688.tar.bz2
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.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx70
1 files changed, 57 insertions, 13 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index c9885ae..550165b 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1229,6 +1229,16 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
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 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
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::UpdateDependencies(const char* tgtInfo,
}
//----------------------------------------------------------------------------
-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 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(const char* tgtInfo)
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 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(const char* tgtInfo)
}
// 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 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(const char* tgtInfo)
}
//----------------------------------------------------------------------------
+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)
{