summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmFindLibraryCommand.cxx51
-rw-r--r--Source/cmFindLibraryCommand.h4
-rw-r--r--Tests/CMakeOnly/find_library/CMakeLists.txt4
3 files changed, 41 insertions, 18 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 06216cd752..652e697edd 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);
}
}
}
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index f91583bf5d..31a5c3f8df 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -62,6 +62,10 @@ public:
protected:
void AddArchitecturePaths(const char* suffix);
+ void AddArchitecturePath(std::string const& dir,
+ std::string::size_type start_pos,
+ const char* suffix,
+ bool fresh = true);
std::string FindLibrary();
virtual void GenerateDocumentation();
private:
diff --git a/Tests/CMakeOnly/find_library/CMakeLists.txt b/Tests/CMakeOnly/find_library/CMakeLists.txt
index 193889620c..08f9331e11 100644
--- a/Tests/CMakeOnly/find_library/CMakeLists.txt
+++ b/Tests/CMakeOnly/find_library/CMakeLists.txt
@@ -50,9 +50,9 @@ endforeach()
set(CMAKE_SIZEOF_VOID_P 8)
foreach(lib64
lib/64/libtest2.a
- #lib/A/lib64/libtest3.a # known breakage
+ lib/A/lib64/libtest3.a
lib/libtest3.a
- #lib64/A/lib/libtest2.a # known breakage
+ lib64/A/lib/libtest2.a
lib64/A/lib64/libtest1.a
lib64/A/libtest1.a
lib64/libtest1.a