浏览代码

clean up object file build rule, and do not attempt to remove link_directories that are in the build tree

Bill Hoffman 24 年之前
父节点
当前提交
6220a187ba
共有 2 个文件被更改,包括 99 次插入79 次删除
  1. 58 48
      Source/cmUnixMakefileGenerator.cxx
  2. 41 31
      Source/cmUnixMakefileGenerator.h

+ 58 - 48
Source/cmUnixMakefileGenerator.cxx

@@ -397,15 +397,6 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
       libDir != libdirs.end(); ++libDir)
     { 
     std::string libpath = cmSystemTools::EscapeSpaces(libDir->c_str());
-    if (m_LibraryOutputPath.size())
-      {
-      if(m_LibraryOutputPath != libpath 
-         && (libpath.find(m_Makefile->GetHomeOutputDirectory()) 
-             != std::string::npos))
-        {
-        emitted.insert(libpath);
-        }
-      }
     if(emitted.insert(libpath).second)
       {
       std::string::size_type pos = libDir->find("-L");
@@ -422,7 +413,7 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
       linkLibs += " ";
       }
     }
-  
+
   std::string librariesLinked;
   const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries();
   for(cmTarget::LinkLibraries::const_iterator lib = libs.begin();
@@ -646,8 +637,11 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
         this->OutputExecutableRule(fout, l->first.c_str(), l->second);
         break;
       case cmTarget::UTILITY:
+        // This is handled by the OutputCustomRules method
       case cmTarget::INSTALL_FILES:
+        // This is handled by the OutputInstallRules method
       case cmTarget::INSTALL_PROGRAMS:
+        // This is handled by the OutputInstallRules method
 	break;
       }
     }
@@ -1061,7 +1055,6 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
       fout << "# End of source group \"" << name.c_str() << "\"\n\n";
       }
     }  
-
 }
 
 
@@ -1387,6 +1380,55 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
     }
 }
 
+void 
+cmUnixMakefileGenerator::
+OutputBuildObjectFromSource(std::ostream& fout,
+                            const char* shortName,
+                            const cmSourceFile& source,
+                            const char* extraCompileFlags,
+                            bool shared)
+{
+            
+  std::string comment = "Build ";
+  std::string objectFile = std::string(shortName) + ".o";
+  comment += objectFile + "  From ";
+  comment += source.GetFullPath();
+  std::string compileCommand;
+  std::string ext = source.GetSourceExtension();
+  if(ext == "c" )
+    {
+    compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
+    compileCommand += extraCompileFlags;
+    if(shared)
+      {
+      compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
+      }
+    compileCommand += "$(INCLUDE_FLAGS) -c ";
+    compileCommand += source.GetFullPath();
+    compileCommand += " -o ";
+    compileCommand += objectFile;
+    }
+  else
+    {
+    compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) ";
+    compileCommand += extraCompileFlags;
+    if(shared)
+      {
+      compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
+      }
+    compileCommand += "$(INCLUDE_FLAGS) -c ";
+    compileCommand += source.GetFullPath();
+    compileCommand += " -o ";
+    compileCommand += objectFile;
+    }
+  this->OutputMakeRule(fout,
+                       comment.c_str(),
+                       objectFile.c_str(),
+                       source.GetFullPath().c_str(),
+                       compileCommand.c_str());
+}
+
+
 
 void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
 {
@@ -1446,43 +1488,11 @@ void cmUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
         // Only output a rule for each .o once.
         if(rules.find(shortName) == rules.end())
           {
-          std::string comment = "Build ";
-          std::string objectFile = shortName + ".o";
-          comment += objectFile + "  From ";
-          comment += source->GetFullPath();
-          std::string compileCommand;
-          std::string ext = source->GetSourceExtension();
-          if(ext == "c" )
-            {
-            compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_CFLAGS) ";
-            compileCommand += exportsDef;
-            if(shared)
-              {
-              compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
-              }
-            compileCommand += "$(INCLUDE_FLAGS) -c ";
-            compileCommand += source->GetFullPath();
-            compileCommand += " -o ";
-            compileCommand += objectFile;
-            }
-          else
-            {
-            compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXXFLAGS) ";
-            compileCommand += exportsDef;
-            if(shared)
-              {
-              compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
-              }
-            compileCommand += "$(INCLUDE_FLAGS) -c ";
-            compileCommand += source->GetFullPath();
-            compileCommand += " -o ";
-            compileCommand += objectFile;
-            }
-          this->OutputMakeRule(fout,
-                               comment.c_str(),
-                               objectFile.c_str(),
-                               source->GetFullPath().c_str(),
-                               compileCommand.c_str());
+          this->OutputBuildObjectFromSource(fout,
+                                            shortName.c_str(),
+                                            *source,
+                                            exportsDef.c_str(),
+                                            shared);
           rules.insert(shortName);
           }
         }

+ 41 - 31
Source/cmUnixMakefileGenerator.h

@@ -56,7 +56,7 @@ public:
   ///! Set cache only and recurse to false by default.
   cmUnixMakefileGenerator();
 
-  ~cmUnixMakefileGenerator();
+  virtual ~cmUnixMakefileGenerator();
   
   ///! Get the name for the generator.
   virtual const char* GetName() {return "Unix Makefiles";}
@@ -91,7 +91,7 @@ public:
    * in the makefile.  These would have been generated
    * by the class cmMakeDepend.
    */
-  void OutputObjectDepends(std::ostream&);
+  virtual void OutputObjectDepends(std::ostream&);
 
   /**
    * Try to determine system infomation such as shared library
@@ -99,36 +99,46 @@ public:
    */
   virtual void ComputeSystemInfo();
 
-private:
-  void RecursiveGenerateCacheOnly();
-  void ProcessDepends(const cmMakeDepend &md);
-  void GenerateCacheOnly();
-  void OutputMakefile(const char* file);
-  void OutputTargetRules(std::ostream& fout);
-  void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
-
-  void OutputSharedLibraryRule(std::ostream&, const char* name, const cmTarget &);
-  void OutputModuleLibraryRule(std::ostream&, const char* name, const cmTarget &);
-  void OutputStaticLibraryRule(std::ostream&, const char* name, const cmTarget &);
-  void OutputExecutableRule(std::ostream&, const char* name, const cmTarget &);
+protected:
+  virtual void RecursiveGenerateCacheOnly();
+  virtual void ProcessDepends(const cmMakeDepend &md);
+  virtual void GenerateCacheOnly();
+  virtual void OutputMakefile(const char* file);
+  virtual void OutputTargetRules(std::ostream& fout);
+  virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &);
+
+  virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
+                                       const cmTarget &);
+  virtual void OutputModuleLibraryRule(std::ostream&, const char* name, 
+                                       const cmTarget &);
+  virtual void OutputStaticLibraryRule(std::ostream&, const char* name,
+                                       const cmTarget &);
+  virtual void OutputExecutableRule(std::ostream&, const char* name,
+                                    const cmTarget &);
+  
+  virtual void OutputTargets(std::ostream&);
+  virtual void OutputSubDirectoryRules(std::ostream&);
+  virtual void OutputDependLibs(std::ostream&);
+  virtual void OutputLibDepend(std::ostream&, const char*);
+  virtual void OutputCustomRules(std::ostream&);
+  virtual void OutputMakeVariables(std::ostream&);
+  virtual void OutputMakeRules(std::ostream&);
+  virtual void OutputInstallRules(std::ostream&);
+  virtual void OutputSourceObjectBuildRules(std::ostream& fout);
+  virtual void OutputBuildObjectFromSource(std::ostream& fout,
+                                           const char* shortName,
+                                           const cmSourceFile& source,
+                                           const char* extraCompileFlags,
+                                           bool sharedTarget);
   
-  void OutputTargets(std::ostream&);
-  void OutputSubDirectoryRules(std::ostream&);
-  void OutputDependInformation(std::ostream&);
-  void OutputDependLibs(std::ostream&);
-  void OutputLibDepend(std::ostream&, const char*);
-  void OutputCustomRules(std::ostream&);
-  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,
-                              const char* target1,
-                              const char* target2,
-                              const std::vector<std::string>& SubDirectories);
-  void OutputMakeRule(std::ostream&, 
+  virtual void OutputSubDirectoryVars(std::ostream& fout,
+                                      const char* var,
+                                      const char* target,
+                                      const char* target1,
+                                      const char* target2,
+                                      const std::vector<std::string>&
+                                      SubDirectories);
+  virtual void OutputMakeRule(std::ostream&, 
                       const char* comment,
                       const char* target,
                       const char* depends,