[cmake-commits] king committed cmDependsFortran.cxx 1.28 1.29

cmake-commits at cmake.org cmake-commits at cmake.org
Sat Dec 15 15:35:03 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv30263/Source

Modified Files:
	cmDependsFortran.cxx 
Log Message:
ENH: Make module timestamps work for modules in subdirectories.  Make sure timestamps for all modules provided by a target are created when the target is done building.


Index: cmDependsFortran.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDependsFortran.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- cmDependsFortran.cxx	15 Dec 2007 01:31:27 -0000	1.28
+++ cmDependsFortran.cxx	15 Dec 2007 20:35:00 -0000	1.29
@@ -122,7 +122,7 @@
     }
 
   // Get the directory in which stamp files will be stored.
-  std::string stamp_dir =
+  std::string mod_dir =
     this->LocalGenerator->GetMakefile()->GetCurrentOutputDirectory();
 
   // Create the parser object.
@@ -157,20 +157,35 @@
     // Require only modules not provided in the same source.
     if(parser.Provides.find(*i) == parser.Provides.end())
       {
+      std::string proxy = mod_dir;
+      proxy += "/";
+      proxy += *i;
+      proxy += ".mod.proxy";
+      proxy = this->LocalGenerator->Convert(proxy.c_str(),
+                                            cmLocalGenerator::HOME_OUTPUT,
+                                            cmLocalGenerator::MAKEFILE);
+
       // since we require some things add them to our list of requirements
-      makeDepends << obj << ".requires: " << i->c_str() << ".mod.proxy"
-         << std::endl;
+      makeDepends << obj << ".requires: " << proxy << std::endl;
 
       // create an empty proxy in case no other source provides it
-      makeDepends << i->c_str() << ".mod.proxy:" << std::endl;
+      makeDepends << proxy << ":" << std::endl;
 
       // The object file should depend on timestamped files for the
       // modules it uses.
       std::string m = cmSystemTools::LowerCase(*i);
-      makeDepends << obj << ": " << m.c_str() << ".mod.stamp\n";
+      std::string stampFile = mod_dir;
+      stampFile += "/";
+      stampFile += m;
+      stampFile += ".mod.stamp";
+      stampFile =
+        this->LocalGenerator->Convert(stampFile.c_str(),
+                                      cmLocalGenerator::HOME_OUTPUT,
+                                      cmLocalGenerator::SHELL);
+      makeDepends << obj << ": " << stampFile << "\n";
 
       // Create a dummy timestamp file for the module.
-      std::string fullPath = stamp_dir;
+      std::string fullPath = mod_dir;
       fullPath += "/";
       fullPath += m;
       fullPath += ".mod.stamp";
@@ -204,13 +219,21 @@
   for(std::set<cmStdString>::const_iterator i = parser.Provides.begin();
       i != parser.Provides.end(); ++i)
     {
-    makeDepends << i->c_str() << ".mod.proxy: " << obj
-      << ".provides" << std::endl;
+    std::string proxy = mod_dir;
+    proxy += "/";
+    proxy += *i;
+    proxy += ".mod.proxy";
+    proxy = this->LocalGenerator->Convert(proxy.c_str(),
+                                          cmLocalGenerator::HOME_OUTPUT,
+                                          cmLocalGenerator::MAKEFILE);
+    makeDepends << proxy << ": " << obj << ".provides" << std::endl;
     }
   
   // If any modules are provided then they must be converted to stamp files.
   if(!parser.Provides.empty())
     {
+    // Create a target to copy the module after the object file
+    // changes.
     makeDepends << obj << ".provides.build:\n";
     for(std::set<cmStdString>::const_iterator i = parser.Provides.begin();
         i != parser.Provides.end(); ++i)
@@ -219,11 +242,33 @@
       // cmake_copy_f90_mod will call back to this class, which will
       // try various cases for the real mod file name.
       std::string m = cmSystemTools::LowerCase(*i);
+      std::string modFile = mod_dir;
+      modFile += "/";
+      modFile += *i;
+      modFile =
+        this->LocalGenerator->Convert(modFile.c_str(),
+                                      cmLocalGenerator::HOME_OUTPUT,
+                                      cmLocalGenerator::SHELL);
+      std::string stampFile = mod_dir;
+      stampFile += "/";
+      stampFile += m;
+      stampFile += ".mod.stamp";
+      stampFile =
+        this->LocalGenerator->Convert(stampFile.c_str(),
+                                      cmLocalGenerator::HOME_OUTPUT,
+                                      cmLocalGenerator::SHELL);
       makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
-         << i->c_str() << " " << m.c_str() << ".mod.stamp\n";
+                  << modFile << " " << stampFile << "\n";
       }
+    // After copying the modules update the timestamp file so that
+    // copying will not be done again until the source rebuilds.
     makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj 
                 << ".provides.build\n";
+
+    // Make sure the module timestamp rule is evaluated by the time
+    // the target finishes building.
+    makeDepends << cmSystemTools::GetFilenamePath(obj) << "/build: "
+                << obj << ".provides.build\n";
     }
 
   /*
@@ -297,12 +342,15 @@
 
   std::string mod = args[2];
   std::string stamp = args[3];
-  std::string mod_upper = cmSystemTools::UpperCase(mod.c_str());
-  std::string mod_lower = cmSystemTools::LowerCase(mod.c_str());
+  std::string mod_dir = cmSystemTools::GetFilenamePath(mod);
+  if(!mod_dir.empty()) { mod_dir += "/"; }
+  std::string mod_upper = mod_dir;
+  mod_upper += cmSystemTools::UpperCase(cmSystemTools::GetFilenameName(mod));
+  std::string mod_lower = mod_dir;
+  mod_lower += cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(mod));
   mod += ".mod";
   mod_upper += ".mod";
   mod_lower += ".mod";
-
   if(cmSystemTools::FileExists(mod_upper.c_str(), true))
     {
     if(!cmSystemTools::CopyFileIfDifferent(mod_upper.c_str(), stamp.c_str()))



More information about the Cmake-commits mailing list