| 154 | } |
| 155 | |
| 156 | void cmSearchPath::AddPrefixPaths(std::vector<std::string> const& paths) |
| 157 | { |
| 158 | assert(this->FC); |
| 159 | |
| 160 | // default for programs |
| 161 | std::string subdir = "bin"; |
| 162 | |
| 163 | if (this->FC->CMakePathName == "INCLUDE") { |
| 164 | subdir = "include"; |
| 165 | } else if (this->FC->CMakePathName == "LIBRARY") { |
| 166 | subdir = "lib"; |
| 167 | } else if (this->FC->CMakePathName == "FRAMEWORK") { |
| 168 | subdir.clear(); // ? what to do for frameworks ? |
| 169 | } |
| 170 | |
| 171 | for (std::string const& path : paths) { |
| 172 | std::string dir = path; |
| 173 | if (!subdir.empty() && !dir.empty() && dir.back() != '/') { |
| 174 | dir += "/"; |
| 175 | } |
| 176 | std::string prefix = dir; |
| 177 | if (!prefix.empty() && prefix != "/") { |
| 178 | prefix.erase(prefix.size() - 1); |
| 179 | } |
| 180 | if (subdir == "include" || subdir == "lib") { |
| 181 | cmValue arch = |
| 182 | this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); |
| 183 | if (cmNonempty(arch)) { |
| 184 | std::string archNoUnknown = *arch; |
| 185 | auto unknownAtPos = archNoUnknown.find("-unknown-"); |
| 186 | bool foundUnknown = unknownAtPos != std::string::npos; |
| 187 | if (foundUnknown) { |
| 188 | // Replace "-unknown-" with "-". |
| 189 | archNoUnknown.replace(unknownAtPos, 9, "-"); |
| 190 | } |
| 191 | if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && |
| 192 | this->FC->Makefile->IsDefinitionSet( |
| 193 | "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { |
| 194 | if (foundUnknown) { |
| 195 | this->AddPathInternal(cmStrCat('/', archNoUnknown, dir, subdir), |
| 196 | cmStrCat('/', archNoUnknown, prefix)); |
| 197 | } |
| 198 | this->AddPathInternal(cmStrCat('/', *arch, dir, subdir), |
| 199 | cmStrCat('/', *arch, prefix)); |
| 200 | } else { |
| 201 | if (foundUnknown) { |
| 202 | this->AddPathInternal(cmStrCat(dir, subdir, '/', archNoUnknown), |
| 203 | prefix); |
| 204 | } |
| 205 | this->AddPathInternal(cmStrCat(dir, subdir, '/', *arch), prefix); |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | std::string add = dir + subdir; |
| 210 | if (add != "/") { |
| 211 | this->AddPathInternal(add, prefix); |
| 212 | } |
| 213 | if (subdir == "bin") { |
no test coverage detected