From 4305195024ea2374de63f7d618a26c2107e3e5c0 Mon Sep 17 00:00:00 2001
From: Conrad Poelman <cpcmakeorg@stellarscience.com>
Date: Thu, 1 Apr 2010 01:23:43 -0600
Subject: [PATCH 1/3] Improve clarity of messages that get printed when CMake needs to be rerun; now says what was older than what.
 Tweak RenameFile to keep a backup copy of the old file.

---
 Source/cmSystemTools.cxx |    5 ++++-
 Source/cmake.cxx         |   25 +++++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index d176987..8b326e7 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1165,7 +1165,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
     else
       {
       /* This is not Win9x.  Use the MoveFileEx implementation.  */
-      return MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) != 0;
+      //return MoveFileEx(oldname, newname, MOVEFILE_REPLACE_EXISTING) != 0;
+      // TEMP DEBUGGING HACK! First, save the old one too!
+      MoveFileEx(newname, (newname+std::string(".bak")).c_str(), MOVEFILE_REPLACE_EXISTING);
+      return MoveFile(oldname, newname) != 0;
       }
     }
   else
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f766d47..ebf2b1a 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3887,8 +3887,9 @@ static bool cmakeCheckStampFile(const char* stampName)
     {
     // The stamp dependencies file cannot be read.  Just assume the
     // build system is really out of date.
-    std::cout << "CMake is re-running because " << stampName
-              << " dependency file is missing.\n";
+    std::cout << "CMake is re-running because file " << stampDepends
+              << " (in " << cmSystemTools::GetCurrentWorkingDirectory()
+              << ") is missing.\n";
     return false;
     }
 
@@ -3904,8 +3905,9 @@ static bool cmakeCheckStampFile(const char* stampName)
       {
       // The stamp depends file is older than this dependency.  The
       // build system is really out of date.
-      std::cout << "CMake is re-running because " << stampName
-                << " is out-of-date.\n";
+      std::cout << "CMake is re-running because file " << stampDepends
+                << " (in " << cmSystemTools::GetCurrentWorkingDirectory()
+                << ") is older than file " << dep << ".\n";
       return false;
       }
     }
@@ -3936,15 +3938,18 @@ static bool cmakeCheckStampList(const char* stampList)
   // If the stamp list does not exist CMake must rerun to generate it.
   if(!cmSystemTools::FileExists(stampList))
     {
-    std::cout << "CMake is re-running because generate.stamp.list "
-              << "is missing.\n";
+    std::cout << "CMake is re-running because " << stampList
+              << " (in " << cmSystemTools::GetCurrentWorkingDirectory()
+              << ") is missing.\n";
     return false;
     }
+  std::string saveStampListDirectory = cmSystemTools::GetCurrentWorkingDirectory();
   std::ifstream fin(stampList);
   if(!fin)
     {
-    std::cout << "CMake is re-running because generate.stamp.list "
-              << "could not be read.\n";
+    std::cout << "CMake is re-running because " << stampList
+              << " (in " << cmSystemTools::GetCurrentWorkingDirectory()
+              << ") could not be read.\n";
     return false;
     }
 
@@ -3954,6 +3959,10 @@ static bool cmakeCheckStampList(const char* stampList)
     {
     if(!cmakeCheckStampFile(stampName.c_str()))
       {
+      // cmakeCheckStampFile() already printed an error; explain more about
+      // where the information came from.
+      std::cout << "(Stamp '" << stampName << "' read from " << stampList
+                << " in " << saveStampListDirectory << ".)\n";
       return false;
       }
     }
-- 
1.7.0.2.msysgit.0

