summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx31
1 files changed, 31 insertions, 0 deletions
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;
+}