| 39 | } |
| 40 | |
| 41 | void cmLocalVisualStudioGenerator::ComputeObjectFilenames( |
| 42 | std::map<cmSourceFile const*, cmObjectLocations>& mapping, |
| 43 | std::string const& config, cmGeneratorTarget const* gt) |
| 44 | { |
| 45 | char const* custom_ext = gt->GetCustomObjectExtension(); |
| 46 | std::string dir_max = this->ComputeLongestObjectDirectory(gt); |
| 47 | |
| 48 | // Count the number of object files with each name. Note that |
| 49 | // windows file names are not case sensitive. |
| 50 | std::map<std::string, int> counts; |
| 51 | |
| 52 | for (auto const& si : mapping) { |
| 53 | cmSourceFile const* sf = si.first; |
| 54 | std::string baseObjectName; |
| 55 | if (gt->GetUseShortObjectNames()) { |
| 56 | baseObjectName = this->GetShortObjectFileName(*sf); |
| 57 | } else { |
| 58 | auto customObjectName = this->GetCustomObjectFileName(*sf); |
| 59 | if (customObjectName.empty()) { |
| 60 | baseObjectName = |
| 61 | cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); |
| 62 | } else { |
| 63 | baseObjectName = std::move(customObjectName); |
| 64 | } |
| 65 | } |
| 66 | std::string objectNameLower = cmSystemTools::LowerCase(baseObjectName); |
| 67 | if (custom_ext) { |
| 68 | objectNameLower += custom_ext; |
| 69 | } else { |
| 70 | objectNameLower += |
| 71 | this->GlobalGenerator->GetLanguageOutputExtension(*sf); |
| 72 | } |
| 73 | counts[objectNameLower] += 1; |
| 74 | } |
| 75 | |
| 76 | // For all source files producing duplicate names we need unique |
| 77 | // object name computation. |
| 78 | |
| 79 | for (auto& si : mapping) { |
| 80 | cmSourceFile const* sf = si.first; |
| 81 | std::string shortObjectName = this->GetShortObjectFileName(*sf); |
| 82 | std::string longObjectName; |
| 83 | auto customObjectName = this->GetCustomObjectFileName(*sf); |
| 84 | if (customObjectName.empty()) { |
| 85 | longObjectName = |
| 86 | cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); |
| 87 | } else { |
| 88 | longObjectName = std::move(customObjectName); |
| 89 | const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); |
| 90 | } |
| 91 | if (custom_ext) { |
| 92 | shortObjectName += custom_ext; |
| 93 | longObjectName += custom_ext; |
| 94 | } else { |
| 95 | shortObjectName += |
| 96 | this->GlobalGenerator->GetLanguageOutputExtension(*sf); |
| 97 | longObjectName += this->GlobalGenerator->GetLanguageOutputExtension(*sf); |
| 98 | } |
nothing calls this directly
no test coverage detected