From b78997d71ddd68247f021bb258f6ffd1e344057b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Mar 2008 17:53:54 -0400 Subject: [PATCH] BUG: Fix subtle bug that prevented Makefile generators from rescanning dependencies when a new source file is added but no other sources are touched. --- Source/cmLocalUnixMakefileGenerator3.cxx | 31 +++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 396dd75cd..158a01970 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -24,6 +24,7 @@ #include "cmSourceFile.h" #include "cmake.h" #include "cmVersion.h" +#include "cmFileTimeComparison.h" // Include dependency scanners for supported languages. Only the // C/C++ scanner is needed for bootstrapping CMake. @@ -1307,15 +1308,39 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo, std::string internalDependFile = dir + "/depend.internal"; std::string dependFile = dir + "/depend.make"; + // If the target DependInfo.cmake file has changed since the last + // time dependencies were scanned then force rescanning. This may + // happen when a new source file is added and CMake regenerates the + // project but no other sources were touched. + bool needRescan = false; + cmFileTimeComparison* ftc = + this->GlobalGenerator->GetCMakeInstance()->GetFileComparison(); + { + int result; + if(!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) || + result < 0) + { + if(verbose) + { + cmOStringStream msg; + msg << "Dependee \"" << tgtInfo + << "\" is newer than depender \"" + << internalDependFile << "\"." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); + } + needRescan = true; + } + } + // Check the implicit dependencies to see if they are up to date. // The build.make file may have explicit dependencies for the object // files but these will not affect the scanning process so they need // not be considered. cmDependsC checker; checker.SetVerbose(verbose); - checker.SetFileComparison - (this->GlobalGenerator->GetCMakeInstance()->GetFileComparison()); - if(!checker.Check(dependFile.c_str(), internalDependFile.c_str())) + checker.SetFileComparison(ftc); + if(needRescan || + !checker.Check(dependFile.c_str(), internalDependFile.c_str())) { // The dependencies must be regenerated. std::string targetName = cmSystemTools::GetFilenameName(dir);