CUDA: Device linking now uses TARGET_OBJECTS content

Due to an oversight in cmLinkLineDeviceComputer object
files did not get propagate to the device linking phase
when given via the `$<TARGET_OBJECTS>` generator expression.
This commit is contained in:
Robert Maynard
2023-09-22 11:13:13 -04:00
parent aa8facefe8
commit cd984261e1
6 changed files with 79 additions and 8 deletions

View File

@@ -101,9 +101,7 @@ void cmLinkLineDeviceComputer::ComputeLinkLibraries(
ItemVector const& items = cli.GetItems();
std::string config = cli.GetConfig();
bool skipItemAfterFramework = false;
// Note:
// Any modification of this algorithm should be reflected also in
// cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions
for (auto const& item : items) {
if (skipItemAfterFramework) {
skipItemAfterFramework = false;
@@ -132,11 +130,13 @@ void cmLinkLineDeviceComputer::ComputeLinkLibraries(
BT<std::string> linkLib;
if (item.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
// nvcc understands absolute paths to libraries ending in '.a' or '.lib'.
// These should be passed to nvlink. Other extensions need to be left
// out because nvlink may not understand or need them. Even though it
// can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value.Value, ".a") ||
// nvcc understands absolute paths to libraries ending in '.o', .a', or
// '.lib'. These should be passed to nvlink. Other extensions need to be
// left out because nvlink may not understand or need them. Even though
// it can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value.Value, ".o") ||
cmHasLiteralSuffix(item.Value.Value, ".obj") ||
cmHasLiteralSuffix(item.Value.Value, ".a") ||
cmHasLiteralSuffix(item.Value.Value, ".lib")) {
linkLib.Value = item
.GetFormattedItem(this->ConvertToOutputFormat(