From e59e9d0e5972ef251157d412d4a0ae341caa379f Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Wed, 10 Aug 2005 12:55:41 -0400 Subject: ENH: fix bug 2087 lib prefix stripped off on windows --- Source/cmGlobalXCodeGenerator.cxx | 6 ++++++ Source/cmLocalGenerator.cxx | 6 ++++++ Source/cmOrderLinkDirectories.cxx | 14 ++++++++++---- Source/cmOrderLinkDirectories.h | 13 ++++++++++--- Tests/Complex/Executable/complex.cxx | 1 + Tests/ComplexOneConfig/Executable/complex.cxx | 1 + Tests/ComplexRelativePaths/Executable/complex.cxx | 1 + 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2a65433..c98f5c0 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1353,6 +1353,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()) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 55249f2..2433414 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1286,6 +1286,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()) { diff --git a/Source/cmOrderLinkDirectories.cxx b/Source/cmOrderLinkDirectories.cxx index afc7a5c..96ece46 100644 --- a/Source/cmOrderLinkDirectories.cxx +++ b/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 = "([^/]*)"; diff --git a/Source/cmOrderLinkDirectories.h b/Source/cmOrderLinkDirectories.h index 6fdf3de..b514081 100644 --- a/Source/cmOrderLinkDirectories.h +++ b/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 m_LinkPathSet; // the names of link extensions std::vector m_LinkExtensions; + // the names of link prefixes + cmStdString m_LinkPrefix; // set of directories that can not be put in the correct order std::set m_ImposibleDirectories; // library regular expressions diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 1a35978..43eb109 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/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); diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 1a35978..43eb109 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/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); diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 1a35978..43eb109 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/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); -- cgit v0.12