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

Method ComputeLinkLibraries

Source/cmLinkLineDeviceComputer.cxx:92–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92void cmLinkLineDeviceComputer::ComputeLinkLibraries(
93 cmComputeLinkInformation& cli, std::string const& stdLibString,
94 std::vector<BT<std::string>>& linkLibraries)
95{
96 // Generate the unique set of link items when device linking.
97 // The nvcc device linker is designed so that each static library
98 // with device symbols only needs to be listed once as it doesn't
99 // care about link order.
100 std::set<std::string> emitted;
101 using ItemVector = cmComputeLinkInformation::ItemVector;
102 ItemVector const& items = cli.GetItems();
103 std::string config = cli.GetConfig();
104 bool skipItemAfterFramework = false;
105
106 for (auto const& item : items) {
107 if (skipItemAfterFramework) {
108 skipItemAfterFramework = false;
109 continue;
110 }
111
112 if (item.Target) {
113 bool skip = false;
114 switch (item.Target->GetType()) {
115 case cmStateEnums::SHARED_LIBRARY:
116 case cmStateEnums::MODULE_LIBRARY:
117 case cmStateEnums::OBJECT_LIBRARY:
118 case cmStateEnums::INTERFACE_LIBRARY:
119 skip = true;
120 break;
121 case cmStateEnums::STATIC_LIBRARY:
122 skip = item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
123 break;
124 default:
125 break;
126 }
127 if (skip) {
128 continue;
129 }
130 }
131
132 BT<std::string> linkLib;
133 if (item.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
134 // nvcc understands absolute paths to libraries ending in '.o', .a', or
135 // '.lib'. These should be passed to nvlink. Other extensions need to be
136 // left out because nvlink may not understand or need them. Even though
137 // it can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
138 if (cmHasLiteralSuffix(item.Value.Value, ".o") ||
139 cmHasLiteralSuffix(item.Value.Value, ".obj") ||
140 cmHasLiteralSuffix(item.Value.Value, ".a") ||
141 cmHasLiteralSuffix(item.Value.Value, ".lib")) {
142 linkLib.Value = item
143 .GetFormattedItem(this->ConvertToOutputFormat(
144 this->ConvertToLinkReference(item.Value.Value)))
145 .Value;
146 }
147 } else if (item.Value == "-framework") {
148 // This is the first part of '-framework Name' where the framework
149 // name is specified as a following item. Ignore both.

Callers

nothing calls this directly

Calls 15

cmHasLiteralSuffixFunction · 0.85
cmLinkItemValidForDeviceFunction · 0.85
GetItemsMethod · 0.80
GetConfigMethod · 0.80
GetFormattedItemMethod · 0.80
GetLinkImplementationMethod · 0.80
emplace_backMethod · 0.80
cmStrCatFunction · 0.70
GetTypeMethod · 0.45
GetPropertyAsBoolMethod · 0.45
ConvertToOutputFormatMethod · 0.45

Tested by

no test coverage detected