summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-26 13:42:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-09-26 13:42:42 (GMT)
commit5a79ea2799e27dc78d71ad71cbf7009416e98076 (patch)
tree1fa0644300a461e87386102a93dbaa149eb77edb /Source
parent5d32320bf33bc874d0f0e0c651235fe6472c8013 (diff)
parentcd984261e1c2f27c2c716d43f3502c829990685d (diff)
downloadCMake-5a79ea2799e27dc78d71ad71cbf7009416e98076.zip
CMake-5a79ea2799e27dc78d71ad71cbf7009416e98076.tar.gz
CMake-5a79ea2799e27dc78d71ad71cbf7009416e98076.tar.bz2
Merge topic 'cuda_handle_target_objects_in_device_link'
cd984261e1 CUDA: Device linking now uses TARGET_OBJECTS content aa8facefe8 CUDA: Visual Studio propagate objects to device linking Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8829
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx16
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx47
2 files changed, 41 insertions, 22 deletions
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index ded6466..28aa5d9 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -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(
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ea4bd06..2a54a55 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -3864,22 +3864,41 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
}
cudaLinkOptions.AppendFlagString("AdditionalOptions", linkFlags);
- // For static libraries that have device linking enabled compute
- // the libraries
- if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY &&
- doDeviceLinking) {
- cmComputeLinkInformation& cli = *pcli;
- cmLinkLineDeviceComputer computer(
- this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory());
- std::vector<BT<std::string>> btLibVec;
- computer.ComputeLinkLibraries(cli, std::string{}, btLibVec);
+ if (doDeviceLinking) {
std::vector<std::string> libVec;
- for (auto const& item : btLibVec) {
- libVec.emplace_back(item.Value);
+ auto const& kinded = this->GeneratorTarget->GetKindedSources(configName);
+ // CMake conversion uses full paths when possible to allow deeper trees.
+ // However, CUDA 8.0 msbuild rules fail on absolute paths so for CUDA
+ // we must use relative paths.
+ const bool forceRelative = true;
+ for (cmGeneratorTarget::SourceAndKind const& si : kinded.Sources) {
+ switch (si.Kind) {
+ case cmGeneratorTarget::SourceKindExternalObject: {
+ std::string path =
+ this->ConvertPath(si.Source.Value->GetFullPath(), forceRelative);
+ ConvertToWindowsSlash(path);
+ libVec.emplace_back(std::move(path));
+ } break;
+ default:
+ break;
+ }
+ }
+ // For static libraries that have device linking enabled compute
+ // the libraries
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ cmComputeLinkInformation& cli = *pcli;
+ cmLinkLineDeviceComputer computer(
+ this->LocalGenerator,
+ this->LocalGenerator->GetStateSnapshot().GetDirectory());
+ std::vector<BT<std::string>> btLibVec;
+ computer.ComputeLinkLibraries(cli, std::string{}, btLibVec);
+ for (auto const& item : btLibVec) {
+ libVec.emplace_back(item.Value);
+ }
+ }
+ if (!libVec.empty()) {
+ cudaLinkOptions.AddFlag("AdditionalDependencies", libVec);
}
-
- cudaLinkOptions.AddFlag("AdditionalDependencies", libVec);
}
this->CudaLinkOptions[configName] = std::move(pOptions);