Browse Source

ENH: some clean up, and better checking to see if we are building cmake

Bill Hoffman 25 years ago
parent
commit
a1ec2852af
2 changed files with 33 additions and 9 deletions
  1. 32 9
      Source/cmUnixMakefileGenerator.cxx
  2. 1 0
      Source/cmUnixMakefileGenerator.h

+ 32 - 9
Source/cmUnixMakefileGenerator.cxx

@@ -1123,8 +1123,34 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
 		       0,
                        "${CMAKE_COMMAND} "
                        "-H${CMAKE_SOURCE_DIR} -B${CMAKE_BINARY_DIR}");
+
+  this->OutputMakeRule(fout, 
+                       "Rule to keep make from removing Makefiles "
+                       "if control-C is hit during a run of cmake.",
+                       ".PRECIOUS",
+                       "Makefile cmake.depends",
+                       0);
+  
+  this->OutputSourceObjectBuildRules(fout);
+  // see if there is already a target for a cmake executable in this
+  // makefile
+  bool buildingCMake = false;
+  std::map<std::string, cmTarget>& targets = m_Makefile->GetTargets();
+  for(cmTargets::const_iterator l = targets.begin(); 
+      l != targets.end(); l++)
+    {
+    if ((l->second.GetType() == cmTarget::EXECUTABLE ||
+         l->second.GetType() == cmTarget::WIN32_EXECUTABLE) &&
+        l->second.IsInAll())
+      {
+      if(l->first == "cmake")
+        {
+        buildingCMake = true;
+        }
+      }
+    }
   // do not put this command in for the cmake project
-  if(strcmp(m_Makefile->GetProjectName(), "CMake") != 0)
+  if(!buildingCMake)
     {
     this->OutputMakeRule(fout, 
                          "Rebuild cmake dummy rule",
@@ -1132,14 +1158,11 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
                          0,
                          "echo \"cmake might be out of date\"");
     }
-  this->OutputMakeRule(fout, 
-                       "Rule to keep make from removing Makefiles "
-                       "if control-C is hit during a run of cmake.",
-                       ".PRECIOUS",
-                       "Makefile cmake.depends",
-                       0);
-  
+}
 
+
+void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
+{
   fout << "# Rules to build .o files from their sources:\n";
 
   std::set<std::string> rules;
@@ -1155,7 +1178,7 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
     for(std::vector<cmSourceFile>::const_iterator source = sources.begin(); 
         source != sources.end(); ++source)
       {
-     if(!source->IsAHeaderFileOnly())
+      if(!source->IsAHeaderFileOnly())
         {
         std::string shortName;
         std::string sourceName;

+ 1 - 0
Source/cmUnixMakefileGenerator.h

@@ -106,6 +106,7 @@ private:
   void OutputMakeVariables(std::ostream&);
   void OutputMakeRules(std::ostream&);
   void OutputInstallRules(std::ostream&);
+  void OutputSourceObjectBuildRules(std::ostream& fout);
   void OutputSubDirectoryVars(std::ostream& fout,
                               const char* var,
                               const char* target,