diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 688d8a765..06216cd75 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -132,44 +132,36 @@ bool cmFindLibraryCommand //---------------------------------------------------------------------------- void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix) { - std::vector newPaths; - bool found = false; + std::vector original; + original.swap(this->SearchPaths); std::string subpath = "lib"; subpath += suffix; subpath += "/"; - for(std::vector::iterator i = this->SearchPaths.begin(); - i != this->SearchPaths.end(); ++i) + for(std::vector::iterator i = original.begin(); + i != original.end(); ++i) { // Try replacing lib/ with lib/ std::string s = *i; cmSystemTools::ReplaceString(s, "lib/", subpath.c_str()); if((s != *i) && cmSystemTools::FileIsDirectory(s.c_str())) { - found = true; - newPaths.push_back(s); + this->SearchPaths.push_back(s); } - // Now look for lib + // Now look for / s = *i; s += suffix; s += "/"; if(cmSystemTools::FileIsDirectory(s.c_str())) { - found = true; - newPaths.push_back(s); + this->SearchPaths.push_back(s); } - // now add the original unchanged path + // Now add the original unchanged path if(cmSystemTools::FileIsDirectory(i->c_str())) { - newPaths.push_back(*i); + this->SearchPaths.push_back(*i); } } - - // If any new paths were found replace the original set. - if(found) - { - this->SearchPaths = newPaths; - } } //----------------------------------------------------------------------------