| 4350 | } |
| 4351 | |
| 4352 | std::string cmLocalGenerator::GetRelativeSourceFileName( |
| 4353 | cmSourceFile const& source) const |
| 4354 | { |
| 4355 | // Construct the object file name using the full path to the source |
| 4356 | // file which is its only unique identification. |
| 4357 | std::string const& fullPath = source.GetFullPath(); |
| 4358 | |
| 4359 | // Try referencing the source relative to the source tree. |
| 4360 | std::string relFromSource = relativeIfUnder( |
| 4361 | this->GetSourceDirectory(), this->GetCurrentSourceDirectory(), fullPath); |
| 4362 | assert(!relFromSource.empty()); |
| 4363 | bool relSource = !cmSystemTools::FileIsFullPath(relFromSource); |
| 4364 | bool subSource = relSource && relFromSource[0] != '.'; |
| 4365 | |
| 4366 | // Try referencing the source relative to the binary tree. |
| 4367 | std::string relFromBinary = relativeIfUnder( |
| 4368 | this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory(), fullPath); |
| 4369 | assert(!relFromBinary.empty()); |
| 4370 | bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary); |
| 4371 | bool subBinary = relBinary && relFromBinary[0] != '.'; |
| 4372 | |
| 4373 | // Select a nice-looking reference to the source file to construct |
| 4374 | // the object file name. |
| 4375 | std::string objectName; |
| 4376 | // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165 |
| 4377 | // NOLINTNEXTLINE(bugprone-branch-clone) |
| 4378 | if ((relSource && !relBinary) || (subSource && !subBinary)) { |
| 4379 | objectName = relFromSource; |
| 4380 | } else if ((relBinary && !relSource) || (subBinary && !subSource) || |
| 4381 | relFromBinary.length() < relFromSource.length()) { |
| 4382 | objectName = relFromBinary; |
| 4383 | } else { |
| 4384 | objectName = relFromSource; |
| 4385 | } |
| 4386 | return objectName; |
| 4387 | } |
| 4388 | |
| 4389 | std::string cmLocalGenerator::GetCustomObjectFileName( |
| 4390 | cmSourceFile const& source) const |
no test coverage detected