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

Method Matches

Source/cmSourceFileLocation.cxx:175–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
176{
177 assert(this->Makefile);
178 if (this->AmbiguousExtension == loc.AmbiguousExtension) {
179 // Both extensions are similarly ambiguous. Since only the old fixed set
180 // of extensions will be tried, the names must match at this point to be
181 // the same file.
182 if (this->Name.size() != loc.Name.size() ||
183 !cmSystemTools::ComparePath(this->Name, loc.Name)) {
184 return false;
185 }
186 } else {
187 cmSourceFileLocation const* loc1;
188 cmSourceFileLocation const* loc2;
189 if (this->AmbiguousExtension) {
190 // Only "this" extension is ambiguous.
191 loc1 = &loc;
192 loc2 = this;
193 } else {
194 // Only "loc" extension is ambiguous.
195 loc1 = this;
196 loc2 = &loc;
197 }
198 if (!loc1->MatchesAmbiguousExtension(*loc2)) {
199 return false;
200 }
201 }
202
203 if (!this->AmbiguousDirectory && !loc.AmbiguousDirectory) {
204 // Both sides have absolute directories.
205 if (this->Directory != loc.Directory) {
206 return false;
207 }
208 } else if (this->AmbiguousDirectory && loc.AmbiguousDirectory) {
209 if (this->Makefile == loc.Makefile) {
210 // Both sides have directories relative to the same location.
211 if (this->Directory != loc.Directory) {
212 return false;
213 }
214 } else {
215 // Each side has a directory relative to a different location.
216 // This can occur when referencing a source file from a different
217 // directory. This is not yet allowed.
218 this->Makefile->IssueMessage(
219 MessageType::INTERNAL_ERROR,
220 "Matches error: Each side has a directory relative to a different "
221 "location. This can occur when referencing a source file from a "
222 "different directory. This is not yet allowed.");
223 return false;
224 }
225 } else if (this->AmbiguousDirectory) {
226 // Compare possible directory combinations.
227 std::string const srcDir = cmSystemTools::CollapseFullPath(
228 this->Directory, this->Makefile->GetCurrentSourceDirectory());
229 std::string const binDir = cmSystemTools::CollapseFullPath(
230 this->Directory, this->Makefile->GetCurrentBinaryDirectory());
231 if (srcDir != loc.Directory && binDir != loc.Directory) {
232 return false;

Callers

nothing calls this directly

Calls 4

UpdateMethod · 0.95
sizeMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected