Преглед на файлове

Fix so that ADD_DEPENDENCIES work (the Utilities dependencies were not output)

Sebastien Barre преди 24 години
родител
ревизия
201764e166
променени са 2 файла, в които са добавени 63 реда и са изтрити 5 реда
  1. 62 5
      Source/cmUnixMakefileGenerator.cxx
  2. 1 0
      Source/cmUnixMakefileGenerator.h

+ 62 - 5
Source/cmUnixMakefileGenerator.cxx

@@ -829,6 +829,22 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout)
           this->OutputLibDepend(fout, lib->first.c_str());
           }
         }
+
+      // Now, look at all utilities specific to this target.
+      const std::set<std::string>& tutils = l->second.GetUtilities();
+      for(std::set<std::string>::const_iterator util = tutils.begin();
+          util != tutils.end(); ++util)
+        {
+        // Record that this utility was used.
+        used.insert(*util);
+
+        // Don't emit the same utility twice for this target.
+        if(emitted.insert(*util).second)
+          {
+          // Output this dependency.
+          this->OutputExeDepend(fout, util->c_str());
+          }
+        }
       
       fout << "\n";
       }
@@ -926,7 +942,6 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
       {
       // if the library is not in the current directory, then get the full
       // path to it
-      libpath = cacheValue;
       if(m_LibraryOutputPath.size())
         {
         libpath = m_LibraryOutputPath;
@@ -934,6 +949,7 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
         }
       else
         {
+        libpath = cacheValue;
         libpath += "/";
         libpath += m_LibraryPrefix;
         }
@@ -955,10 +971,10 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
       libpath += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
       }
     else if (libType && std::string(libType) == "MODULE")
-          {
-          libpath += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX");
-          }
-    else
+      {
+      libpath += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX");
+      }
+    else if (libType && std::string(libType) == "STATIC")
       {
       libpath += m_StaticLibraryExtension;
       }
@@ -968,6 +984,47 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
 }
 
 
+void cmUnixMakefileGenerator::OutputExeDepend(std::ostream& fout,
+                                              const char* name)
+{
+  const char* cacheValue = m_Makefile->GetDefinition(name);
+  if(cacheValue )
+    {
+    // if there is a cache value, then this is a executable/utility that cmake
+    // knows how to build, so we can depend on it
+    std::string exepath;
+    if (!this->SamePath(m_Makefile->GetCurrentOutputDirectory(), cacheValue))
+      {
+      // if the exe/utility is not in the current directory, then get the full
+      // path to it
+      if(m_ExecutableOutputPath.size())
+        {
+        exepath = m_ExecutableOutputPath;
+        }
+      else
+        {
+        exepath = cacheValue;
+        exepath += "/";
+        }
+      }
+    else
+      {
+      // library is in current Makefile
+      exepath = m_ExecutableOutputPath;
+      }
+    // add the library name
+    exepath += name;
+    // add the correct extension
+    if (m_Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX"))
+      {
+      exepath += m_Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
+      }
+    fout << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(exepath.c_str()).c_str())
+         << " ";
+    }
+}
+
+
 
 // fix up names of directories so they can be used
 // as targets in makefiles.

+ 1 - 0
Source/cmUnixMakefileGenerator.h

@@ -127,6 +127,7 @@ protected:
   virtual void OutputSubDirectoryRules(std::ostream&);
   virtual void OutputDependLibs(std::ostream&);
   virtual void OutputLibDepend(std::ostream&, const char*);
+  virtual void OutputExeDepend(std::ostream&, const char*);
   virtual void OutputCustomRules(std::ostream&);
   virtual void OutputMakeVariables(std::ostream&);
   virtual void OutputMakeRules(std::ostream&);