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

Method ComputeObjectFilenames

Source/cmLocalGhsMultiGenerator.cxx:48–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46}
47
48void 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}

Callers

nothing calls this directly

Calls 12

moveFunction · 0.85
GetSupportDirectoryMethod · 0.80
AddExplicitObjectNameMethod · 0.80
emplaceMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
GetFullPathMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected