| 113 | } |
| 114 | |
| 115 | void cmFindLibraryCommand::AddArchitecturePath( |
| 116 | std::string const& dir, std::string::size_type start_pos, char const* suffix, |
| 117 | bool fresh) |
| 118 | { |
| 119 | std::string::size_type pos = dir.find("lib/", start_pos); |
| 120 | |
| 121 | if (pos != std::string::npos) { |
| 122 | // Check for "lib". |
| 123 | std::string lib = dir.substr(0, pos + 3); |
| 124 | bool use_lib = cmSystemTools::FileIsDirectory(lib); |
| 125 | |
| 126 | // Check for "lib<suffix>" and use it first. |
| 127 | std::string libX = lib + suffix; |
| 128 | bool use_libX = cmSystemTools::FileIsDirectory(libX); |
| 129 | |
| 130 | // Avoid copies of the same directory due to symlinks. |
| 131 | if (use_libX && use_lib && cmLibDirsLinked(libX, lib)) { |
| 132 | use_libX = false; |
| 133 | } |
| 134 | |
| 135 | if (use_libX) { |
| 136 | libX += dir.substr(pos + 3); |
| 137 | std::string::size_type libX_pos = pos + 3 + strlen(suffix) + 1; |
| 138 | this->AddArchitecturePath(libX, libX_pos, suffix); |
| 139 | } |
| 140 | |
| 141 | if (use_lib) { |
| 142 | this->AddArchitecturePath(dir, pos + 3 + 1, suffix, false); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | if (fresh) { |
| 147 | // Check for the original unchanged path. |
| 148 | bool use_dir = cmSystemTools::FileIsDirectory(dir); |
| 149 | |
| 150 | // Check for <dir><suffix>/ and use it first. |
| 151 | std::string dirX = dir + suffix; |
| 152 | bool use_dirX = cmSystemTools::FileIsDirectory(dirX); |
| 153 | |
| 154 | // Avoid copies of the same directory due to symlinks. |
| 155 | if (use_dirX && use_dir && cmLibDirsLinked(dirX, dir)) { |
| 156 | use_dirX = false; |
| 157 | } |
| 158 | |
| 159 | if (use_dirX) { |
| 160 | dirX += "/"; |
| 161 | if (this->DebugModeEnabled()) { |
| 162 | std::string msg = cmStrCat( |
| 163 | "find_library(", this->VariableName, ") added replacement path ", |
| 164 | dirX, " to PATH_SUFFIXES for architecture suffix '", suffix, '\''); |
| 165 | this->DebugMessage(msg); |
| 166 | } |
| 167 | this->SearchPaths.push_back(std::move(dirX)); |
| 168 | } |
| 169 | |
| 170 | if (use_dir) { |
| 171 | this->SearchPaths.push_back(dir); |
| 172 | if (this->DebugModeEnabled()) { |
no test coverage detected