MCPcopy Create free account
hub / github.com/Kitware/CMake / AddPrefixPaths

Method AddPrefixPaths

Source/cmSearchPath.cxx:156–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156void 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") {

Callers 4

AddCMakePrefixPathMethod · 0.95
AddEnvPrefixPathMethod · 0.95
FillPackageRootPathMethod · 0.80

Calls 11

AddPathInternalMethod · 0.95
cmNonemptyFunction · 0.85
eraseMethod · 0.80
IsDefinitionSetMethod · 0.80
cmStrCatFunction · 0.70
clearMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
sizeMethod · 0.45
GetDefinitionMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected