浏览代码

ENH: Add support for adding object files and sources. This way you can use external program such as assembler or fortran to generate object files. Also star of fixing: Bug #757 - add .o file as a source file

Andy Cedilnik 21 年之前
父节点
当前提交
af61b68583
共有 2 个文件被更改,包括 48 次插入9 次删除
  1. 43 9
      Source/cmLocalUnixMakefileGenerator.cxx
  2. 5 0
      Source/cmSourceFile.cxx

+ 43 - 9
Source/cmLocalUnixMakefileGenerator.cxx

@@ -533,11 +533,28 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
           {
           std::string outExt(
             this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
-          if(outExt.size())
+          if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
             {
-            fout << "\\\n" 
-                 << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
-                 << outExt.c_str() << " ";
+            fout << "\\\n";
+            fout << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
+              << outExt.c_str() << " ";
+            }
+          }
+        }
+      fout << "\n\n";
+      fout << this->CreateMakeVariable(l->first.c_str(), "_EXTERNAL_OBJS") << " = ";
+      for(std::vector<cmSourceFile*>::iterator i = classes.begin(); 
+          i != classes.end(); i++)
+        {
+        if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") && 
+           !(*i)->GetCustomCommand())
+          {
+          std::string outExt(
+            this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
+          if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+            {
+            fout << "\\\n";
+            fout << this->ConvertToMakeTarget(this->ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()).c_str()) << " ";
             }
           }
         }
@@ -550,7 +567,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
            !(*i)->GetCustomCommand())
           {
           std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
-          if(outExt.size())
+          if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
             {
             fout << "\\\n\"" << this->ConvertToMakeTarget(ConvertToRelativeOutputPath((*i)->GetSourceName().c_str()).c_str())
                  << outExt.c_str() << "\" ";
@@ -558,6 +575,21 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
           }
         }
       fout << "\n\n";
+      fout << this->CreateMakeVariable(l->first.c_str(), "_EXTERNAL_OBJS_QUOTED") << " = ";
+      for(std::vector<cmSourceFile*>::iterator i = classes.begin(); 
+          i != classes.end(); i++)
+        {
+        if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+           !(*i)->GetCustomCommand())
+          {
+          std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
+          if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
+            {
+            fout << "\\\n\"" << this->ConvertToMakeTarget(ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()).c_str()) << "\" ";
+            }
+          }
+        }
+      fout << "\n\n";
       }
     }
 
@@ -1115,8 +1147,8 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
     }
 
   // get the objects that are used to link this library
-  std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
-  std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") ";
+  std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
+  std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS_QUOTED") + ") ";
   // create a variable with the objects that this library depends on
   std::string depend =
     objs + " $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
@@ -1382,9 +1414,10 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
     {
     needsLocalTarget = true;
     }
-  std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") ";
+  std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
   std::string depend = "$(";
   depend += this->CreateMakeVariable(name, "_SRC_OBJS") 
+    + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") 
     + ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
   std::vector<std::string> rules;
   linkFlags += this->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
@@ -2661,6 +2694,8 @@ OutputBuildObjectFromSource(std::ostream& fout,
       return;
     case cmSystemTools::DEFINITION_FILE_FORMAT:
       return;
+    case cmSystemTools::OBJECT_FILE_FORMAT:
+      return;
     case cmSystemTools::RESOURCE_FILE_FORMAT:
       {
       flags = " $(INCLUDE_FLAGS) ";
@@ -2677,7 +2712,6 @@ OutputBuildObjectFromSource(std::ostream& fout,
     case cmSystemTools::STATIC_LIBRARY_FILE_FORMAT:
     case cmSystemTools::SHARED_LIBRARY_FILE_FORMAT:
     case cmSystemTools::MODULE_FILE_FORMAT:
-    case cmSystemTools::OBJECT_FILE_FORMAT:
     case cmSystemTools::UNKNOWN_FILE_FORMAT:
       cmSystemTools::Error("Unexpected file type ",
                            sourceFile.c_str());

+ 5 - 0
Source/cmSourceFile.cxx

@@ -73,6 +73,11 @@ void cmSourceFile::SetName(const char* name, const char* dir,
       this->SetProperty("HEADER_FILE_ONLY","0");
       }
     m_FullPath = hname;
+    if ( m_SourceExtension == "obj" || m_SourceExtension == "o" ||
+      m_SourceExtension == "lo" )
+      {
+      this->SetProperty("EXTERNAL_OBJECT", "1");
+      }
     return;
     }