summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmComputeLinkInformation.cxx25
-rw-r--r--Source/cmOrderDirectories.cxx10
-rw-r--r--Source/cmSystemTools.cxx31
-rw-r--r--Source/cmSystemTools.h4
4 files changed, 64 insertions, 6 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 1da512c..1899bd2 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -27,6 +27,8 @@
#include <ctype.h>
+//#define CM_COMPUTE_LINK_INFO_DEBUG
+
/*
Notes about linking on various platforms:
@@ -905,7 +907,7 @@ cmComputeLinkInformation
}
// Finish the list.
- libext += ").*";
+ libext += ")$";
return libext;
}
@@ -1070,6 +1072,13 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
return false;
}
+ // Only apply the policy below if the library file is one that can
+ // be found by the linker.
+ if(!this->ExtractAnyLibraryName.find(item))
+ {
+ return false;
+ }
+
// Many system linkers support multiple architectures by
// automatically selecting the implicit linker search path for the
// current architecture. If the library appears in an implicit link
@@ -1262,13 +1271,19 @@ bool cmComputeLinkInformation::CheckSharedLibNoSOName(std::string const& item)
{
// This platform will use the path to a library as its soname if the
// library is given via path and was not built with an soname. If
- // this is a shared library that might be the case. TODO: Check if
- // the lib is a symlink to detect that it actually has an soname.
+ // this is a shared library that might be the case.
std::string file = cmSystemTools::GetFilenameName(item);
if(this->ExtractSharedLibraryName.find(file))
{
- this->AddSharedLibNoSOName(item);
- return true;
+ // If we can guess the soname fairly reliably then assume the
+ // library has one. Otherwise assume the library has no builtin
+ // soname.
+ std::string soname;
+ if(!cmSystemTools::GuessLibrarySOName(item, soname))
+ {
+ this->AddSharedLibNoSOName(item);
+ return true;
+ }
}
return false;
}
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 7bc5dd6..a0ff9c1 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -119,6 +119,15 @@ public:
const char* soname):
cmOrderDirectoriesConstraint(od, file), SOName(soname? soname : "")
{
+ if(this->SOName.empty())
+ {
+ // Try to guess the soname.
+ std::string soguess;
+ if(cmSystemTools::GuessLibrarySOName(file, soguess))
+ {
+ this->SOName = soguess;
+ }
+ }
}
virtual void Report(std::ostream& e)
@@ -164,7 +173,6 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
// Get the set of files that might conflict. Since we do not
// know the soname just look at all files that start with the
// file name. Usually the soname starts with the library name.
- // TODO: Check if the library is a symlink and guess the soname.
std::string base = this->FileName;
std::set<cmStdString>::const_iterator first = files.lower_bound(base);
++base[base.size()-1];
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 002dc0b..8d13e11 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2150,3 +2150,34 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message,
}
}
#endif
+
+//----------------------------------------------------------------------------
+bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
+ std::string& soname)
+{
+ // If the file is not a symlink we have no guess for its soname.
+ if(!cmSystemTools::FileIsSymlink(fullPath.c_str()))
+ {
+ return false;
+ }
+ if(!cmSystemTools::ReadSymlink(fullPath.c_str(), soname))
+ {
+ return false;
+ }
+
+ // If the symlink has a path component we have no guess for the soname.
+ if(!cmSystemTools::GetFilenamePath(soname).empty())
+ {
+ return false;
+ }
+
+ // If the symlink points at an extended version of the same name
+ // assume it is the soname.
+ std::string name = cmSystemTools::GetFilenameName(fullPath);
+ if(soname.length() > name.length() &&
+ soname.substr(0, name.length()) == name)
+ {
+ return true;
+ }
+ return false;
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 3bf22f7..e03c24c 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -377,6 +377,10 @@ public:
bool newLine, bool enabled);
#endif
+ /** Try to guess the soname of a shared library. */
+ static bool GuessLibrarySOName(std::string const& fullPath,
+ std::string& soname);
+
private:
static bool s_ForceUnixPaths;
static bool s_RunCommandHideConsole;