Просмотр исходного кода

bug: fix same path comparison when short paths are used

Bill Hoffman 24 лет назад
Родитель
Сommit
ed50410ae7

+ 12 - 1
Source/cmNMakeMakefileGenerator.cxx

@@ -549,7 +549,18 @@ void cmNMakeMakefileGenerator::OutputIncludeMakefile(std::ostream& fout,
   fout << "!include " << file << "\n";
 }
 
-
+bool cmNMakeMakefileGenerator::SamePath(const char* path1, const char* path2)
+{
+  // first check to see if they are the same anyway
+  if (strcmp(path1, path2) == 0)
+    {
+    return true;
+    }
+  // next short path and lower case both of them for the compare
+  return 
+    cmSystemTools::LowerCase(ShortPath(path1)) ==
+    cmSystemTools::LowerCase(ShortPath(path2));
+}
 
 void cmNMakeMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
 						       const char* path,

+ 3 - 1
Source/cmNMakeMakefileGenerator.h

@@ -103,7 +103,9 @@ protected:
   virtual void OutputBuildLibraryInDir(std::ostream& fout,
 				       const char* path,
 				       const char* library,
-				       const char* fullpath);
+				       const char* fullpath); 
+  ///! return true if the two paths are the same (checks short paths)
+  virtual bool SamePath(const char* path1, const char* path2);
 private:
   bool m_QuoteNextCommand;      // if this is true, OutputMakeRule
                                 // will not quote the next commands

+ 9 - 3
Source/cmUnixMakefileGenerator.cxx

@@ -762,8 +762,8 @@ void cmUnixMakefileGenerator::OutputDependLibs(std::ostream& fout)
     const char* cacheValue = m_Makefile->GetDefinition(lib->c_str());
     // if cache and not the current directory add a rule, to
     // jump into the directory and build for the first time
-    if(cacheValue 
-       && (strcmp(m_Makefile->GetCurrentOutputDirectory(), cacheValue) != 0))
+    if(cacheValue &&
+       (!this->SamePath(m_Makefile->GetCurrentOutputDirectory(), cacheValue)))
       {
       std::string library = m_LibraryPrefix;
       library += *lib;
@@ -811,6 +811,12 @@ void cmUnixMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
        << ":\n\tcd " << cmSystemTools::EscapeSpaces(path)
            << "; $(MAKE) " << fullpath << "\n\n"; 
 }
+
+bool cmUnixMakefileGenerator::SamePath(const char* path1, const char* path2)
+{
+  return strcmp(path1, path2) == 0;
+}
+
 void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
                                               const char* name)
 {
@@ -820,7 +826,7 @@ void cmUnixMakefileGenerator::OutputLibDepend(std::ostream& fout,
     // if there is a cache value, then this is a library that cmake
     // knows how to build, so we can depend on it
     std::string libpath;
-    if (strcmp(m_Makefile->GetCurrentOutputDirectory(), cacheValue) != 0)
+    if (!this->SamePath(m_Makefile->GetCurrentOutputDirectory(), cacheValue))
       {
       // if the library is not in the current directory, then get the full
       // path to it

+ 2 - 0
Source/cmUnixMakefileGenerator.h

@@ -155,6 +155,8 @@ protected:
 				       const char* path,
 				       const char* library,
 				       const char* fullpath);
+  ///! return true if the two paths are the same
+  virtual bool SamePath(const char* path1, const char* path2);
   virtual std::string GetOutputExtension(const char* sourceExtension);
   virtual void OutputIncludeMakefile(std::ostream&, const char* file);
   void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;}