| 46 | } |
| 47 | |
| 48 | void cmLocalGhsMultiGenerator::ComputeObjectFilenames( |
| 49 | std::map<cmSourceFile const*, cmObjectLocations>& mapping, |
| 50 | std::string const& config, cmGeneratorTarget const* gt) |
| 51 | { |
| 52 | std::string dir_max = cmStrCat(gt->GetSupportDirectory(), '/'); |
| 53 | |
| 54 | // Count the number of object files with each name. Note that |
| 55 | // filesystem may not be case sensitive. |
| 56 | std::map<std::string, int> counts; |
| 57 | |
| 58 | for (auto const& si : mapping) { |
| 59 | cmSourceFile const* sf = si.first; |
| 60 | std::string objectName; |
| 61 | auto customObjectName = this->GetCustomObjectFileName(*sf); |
| 62 | if (customObjectName.empty()) { |
| 63 | objectName = |
| 64 | cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); |
| 65 | } else { |
| 66 | objectName = std::move(customObjectName); |
| 67 | } |
| 68 | objectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); |
| 69 | std::string objectNameLower = cmSystemTools::LowerCase(objectName); |
| 70 | counts[objectNameLower] += 1; |
| 71 | } |
| 72 | |
| 73 | // For all source files producing duplicate names we need unique |
| 74 | // object name computation. |
| 75 | for (auto& si : mapping) { |
| 76 | cmSourceFile const* sf = si.first; |
| 77 | bool forceShortObjectName = true; |
| 78 | std::string shortObjectName = this->GetObjectFileNameWithoutTarget( |
| 79 | *sf, dir_max, nullptr, nullptr, &forceShortObjectName); |
| 80 | std::string longObjectName; |
| 81 | auto customObjectName = this->GetCustomObjectFileName(*sf); |
| 82 | if (customObjectName.empty()) { |
| 83 | longObjectName = |
| 84 | cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); |
| 85 | } else { |
| 86 | longObjectName = std::move(customObjectName); |
| 87 | const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); |
| 88 | } |
| 89 | longObjectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); |
| 90 | |
| 91 | if (counts[cmSystemTools::LowerCase(longObjectName)] > 1) { |
| 92 | const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); |
| 93 | forceShortObjectName = false; |
| 94 | longObjectName = this->GetObjectFileNameWithoutTarget( |
| 95 | *sf, dir_max, nullptr, nullptr, &forceShortObjectName); |
| 96 | cmsys::SystemTools::ReplaceString(longObjectName, "/", "_"); |
| 97 | } |
| 98 | si.second.ShortLoc.emplace(shortObjectName); |
| 99 | si.second.LongLoc.Update(longObjectName); |
| 100 | this->FillCustomInstallObjectLocations(*sf, config, nullptr, |
| 101 | si.second.InstallLongLoc); |
| 102 | } |
| 103 | } |
nothing calls this directly
no test coverage detected