Browse Source

ENH: fix bug 2087 lib prefix stripped off on windows

Bill Hoffman 20 years ago
parent
commit
e59e9d0e59

+ 6 - 0
Source/cmGlobalXCodeGenerator.cxx

@@ -1352,6 +1352,12 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
     {
     orderLibs.AddLinkExtension(ext.c_str());
     }
+  ext = 
+    m_CurrentMakefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX");
+  if(ext.size())
+    {
+    orderLibs.SetLinkPrefix(ext.c_str());
+    }
   ext = 
     m_CurrentMakefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX");
   if(ext.size())

+ 6 - 0
Source/cmLocalGenerator.cxx

@@ -1285,6 +1285,12 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
     {
     orderLibs.AddLinkExtension(ext.c_str());
     }
+  ext = 
+    m_Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX");
+  if(ext.size())
+    {
+    orderLibs.SetLinkPrefix(ext.c_str());
+    }
   ext = 
     m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX");
   if(ext.size())

+ 10 - 4
Source/cmOrderLinkDirectories.cxx

@@ -115,17 +115,23 @@ void cmOrderLinkDirectories::CreateRegularExpressions()
       }
     first = false;
     libext += "\\";
-#ifndef _WIN32    
-    libext += *i;
-#else
+#if defined(_WIN32) && !defined(__CYGWIN__)
     libext += this->NoCaseExpression(i->c_str());
+#else
+    libext += *i;
 #endif
     }
   libext += ").*";
   cmStdString reg("(.*)");
   reg += libext;
   m_RemoveLibraryExtension.compile(reg.c_str());
-  reg = "^lib([^/]*)";
+  reg = "";
+  if(m_LinkPrefix.size())
+    {
+    reg = "^";
+    reg += m_LinkPrefix;
+    }
+  reg += "([^/]*)";
   reg += libext;
   m_ExtractBaseLibraryName.compile(reg.c_str());
   reg = "([^/]*)";

+ 10 - 3
Source/cmOrderLinkDirectories.h

@@ -64,9 +64,14 @@ public:
   // CMAKE_SHARED_LIBRARY_SUFFIX
   // CMAKE_LINK_LIBRARY_SUFFIX
   void AddLinkExtension(const char* e)
-  {
-    m_LinkExtensions.push_back(e);
-  }
+    {
+      m_LinkExtensions.push_back(e);
+    }
+  // should be set from CMAKE_STATIC_LIBRARY_PREFIX
+  void SetLinkPrefix(const char* s)
+    {
+      m_LinkPrefix = s;
+    }
   // Return any warnings if the exist
   std::string GetWarnings();
   // return a list of all full path libraries
@@ -120,6 +125,8 @@ private:
   std::set<cmStdString> m_LinkPathSet;
   // the names of link extensions
   std::vector<cmStdString> m_LinkExtensions;
+  // the names of link prefixes
+  cmStdString m_LinkPrefix;
   // set of directories that can not be put in the correct order
   std::set<cmStdString> m_ImposibleDirectories;
   // library regular expressions

+ 1 - 0
Tests/Complex/Executable/complex.cxx

@@ -56,6 +56,7 @@ bool TestLibraryOrder(bool shouldFail)
   orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
+  orderLibs.SetLinkPrefix("lib");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
   bool ret = orderLibs.DetermineLibraryPathOrder();
   orderLibs.GetLinkerInformation(sortedpaths, linkItems);

+ 1 - 0
Tests/ComplexOneConfig/Executable/complex.cxx

@@ -56,6 +56,7 @@ bool TestLibraryOrder(bool shouldFail)
   orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
+  orderLibs.SetLinkPrefix("lib");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
   bool ret = orderLibs.DetermineLibraryPathOrder();
   orderLibs.GetLinkerInformation(sortedpaths, linkItems);

+ 1 - 0
Tests/ComplexRelativePaths/Executable/complex.cxx

@@ -56,6 +56,7 @@ bool TestLibraryOrder(bool shouldFail)
   orderLibs.DebugOn();
   orderLibs.AddLinkExtension(".so");
   orderLibs.AddLinkExtension(".a");
+  orderLibs.SetLinkPrefix("lib");
   orderLibs.SetLinkInformation(target, cmTarget::GENERAL, "A");
   bool ret = orderLibs.DetermineLibraryPathOrder();
   orderLibs.GetLinkerInformation(sortedpaths, linkItems);