| 90 | } |
| 91 | |
| 92 | void 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. |
nothing calls this directly
no test coverage detected