summaryrefslogtreecommitdiff
path: root/Source/cmFindLibraryCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-02-28 11:30:14 -0500
committerBrad King <brad.king@kitware.com>2017-02-28 14:56:13 -0500
commite67963ed7316768bf0ebfbe42137d028c0d1d2a4 (patch)
treea7d0604f60c955aab96c438f0b312923b0e4ab25 /Source/cmFindLibraryCommand.cxx
parent2b1cdd85b8943059e5f2b27735df261743749342 (diff)
downloadcmake-e67963ed7316768bf0ebfbe42137d028c0d1d2a4.tar.gz
cmFindLibraryCommand: Refactor AddArchitecturePath logic
Use boolean variables to save results and rename variables to more closely represent their roles.
Diffstat (limited to 'Source/cmFindLibraryCommand.cxx')
-rw-r--r--Source/cmFindLibraryCommand.cxx42
1 files changed, 26 insertions, 16 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 082350f9e3..58d92aa405 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -77,31 +77,41 @@ void cmFindLibraryCommand::AddArchitecturePath(
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)) {
- next_dir += dir.substr(pos + 3);
- std::string::size_type next_pos = pos + 3 + strlen(suffix) + 1;
- this->AddArchitecturePath(next_dir, next_pos, suffix);
+ // Check for "lib".
+ std::string lib = dir.substr(0, pos + 3);
+ bool use_lib = cmSystemTools::FileIsDirectory(lib);
+
+ // Check for "lib<suffix>" and use it first.
+ std::string libX = lib + suffix;
+ bool use_libX = cmSystemTools::FileIsDirectory(libX);
+
+ if (use_libX) {
+ libX += dir.substr(pos + 3);
+ std::string::size_type libX_pos = pos + 3 + strlen(suffix) + 1;
+ this->AddArchitecturePath(libX, libX_pos, suffix);
}
- // Follow "lib".
- if (cmSystemTools::FileIsDirectory(cur_dir)) {
+ if (use_lib) {
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)) {
- this->SearchPaths.push_back(cur_dir);
+ // Check for the original unchanged path.
+ bool use_dir = cmSystemTools::FileIsDirectory(dir);
+
+ // Check for <dir><suffix>/ and use it first.
+ std::string dirX = dir + suffix;
+ bool use_dirX = cmSystemTools::FileIsDirectory(dirX);
+
+ if (use_dirX) {
+ dirX += "/";
+ this->SearchPaths.push_back(dirX);
}
- // Now add the original unchanged path
- if (cmSystemTools::FileIsDirectory(dir)) {
+ if (use_dir) {
this->SearchPaths.push_back(dir);
}
}