summaryrefslogtreecommitdiffstats
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-07-20 18:09:57 (GMT)
committerBrad King <brad.king@kitware.com>2012-07-20 18:19:11 (GMT)
commit733726edf61aa7889b57aa9490cb719c83d3ea0f (patch)
tree7e757a1828ac7e9a936b1161aea7dcb70ba91680 /Source/cmFindLibraryCommand.cxx
parent54add62f1b36ffc25f333762901e14b2def21db2 (diff)
downloadCMake-733726edf61aa7889b57aa9490cb719c83d3ea0f.zip
CMake-733726edf61aa7889b57aa9490cb719c83d3ea0f.tar.gz
CMake-733726edf61aa7889b57aa9490cb719c83d3ea0f.tar.bz2
find_library: Fix mixed lib->lib64 (non-)conversion cases (#13419)
When a search path contains multiple "lib/" instances we previously converted all or none. This fails for cases where only some of the multiple instances must be converted. Teach AddArchitecturePaths to generate all combinations that exist. Uncomment these cases in the CMakeOnly.find_library test now that they work.
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx51
1 files changed, 35 insertions, 16 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 06216cd..652e697 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -134,32 +134,51 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
{
std::vector<std::string> original;
original.swap(this->SearchPaths);
- std::string subpath = "lib";
- subpath += suffix;
- subpath += "/";
for(std::vector<std::string>::iterator i = original.begin();
i != original.end(); ++i)
{
- // Try replacing lib/ with lib<suffix>/
- std::string s = *i;
- cmSystemTools::ReplaceString(s, "lib/", subpath.c_str());
- if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str()))
+ this->AddArchitecturePath(*i, 0, suffix);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmFindLibraryCommand::AddArchitecturePath(
+ std::string const& dir, std::string::size_type start_pos,
+ const char* suffix, bool fresh)
+{
+ std::string::size_type pos = dir.find("lib/", start_pos);
+ if(pos != std::string::npos)
+ {
+ std::string cur_dir = dir.substr(0,pos+3);
+
+ // Follow "lib<suffix>".
+ std::string next_dir = cur_dir + suffix;
+ if(cmSystemTools::FileIsDirectory(next_dir.c_str()))
{
- this->SearchPaths.push_back(s);
+ next_dir += dir.substr(pos+3);
+ std::string::size_type next_pos = pos+3+strlen(suffix)+1;
+ this->AddArchitecturePath(next_dir, next_pos, suffix);
}
- // Now look for <original><suffix>/
- s = *i;
- s += suffix;
- s += "/";
- if(cmSystemTools::FileIsDirectory(s.c_str()))
+ // Follow "lib".
+ if(cmSystemTools::FileIsDirectory(cur_dir.c_str()))
+ {
+ this->AddArchitecturePath(dir, pos+3+1, suffix, false);
+ }
+ }
+ if(fresh)
+ {
+ // Check for <dir><suffix>/.
+ std::string cur_dir = dir + suffix + "/";
+ if(cmSystemTools::FileIsDirectory(cur_dir.c_str()))
{
- this->SearchPaths.push_back(s);
+ this->SearchPaths.push_back(cur_dir);
}
+
// Now add the original unchanged path
- if(cmSystemTools::FileIsDirectory(i->c_str()))
+ if(cmSystemTools::FileIsDirectory(dir.c_str()))
{
- this->SearchPaths.push_back(*i);
+ this->SearchPaths.push_back(dir);
}
}
}