diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-01-07 16:49:09 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-01-09 16:02:17 (GMT) |
commit | 071c4f1a2a44de1e3e9d2c5ce22a661edf334f8b (patch) | |
tree | 03a09c76b2393ac69c4f2bea10c87afa26111807 /Source | |
parent | 5b43aa775507c974284bbae2e6bd13e11caec80d (diff) | |
download | CMake-071c4f1a2a44de1e3e9d2c5ce22a661edf334f8b.zip CMake-071c4f1a2a44de1e3e9d2c5ce22a661edf334f8b.tar.gz CMake-071c4f1a2a44de1e3e9d2c5ce22a661edf334f8b.tar.bz2 |
CUDA: Do not device link if target has no CUDA usage
When CUDA is enabled, and a pure non-CUDA target has
CMAKE_CUDA_SEPARABLE_COMPILATION enabled, don't actually perform
the device linking step, as it will fail. A target that has
CMAKE_CUDA_SEPARABLE_COMPILATION enabled must also have CUDA
usage (either itself, or something it links to).
Fixes: #20182
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLinkLineDeviceComputer.cxx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 8d2add6..2cb2fd6 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -163,33 +163,33 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg, return cmSystemTools::IsOn(resolveDeviceSymbols); } - if (const char* separableCompilation = - target.GetProperty("CUDA_SEPARABLE_COMPILATION")) { - if (cmSystemTools::IsOn(separableCompilation)) { - bool doDeviceLinking = false; - switch (target.GetType()) { - case cmStateEnums::SHARED_LIBRARY: - case cmStateEnums::MODULE_LIBRARY: - case cmStateEnums::EXECUTABLE: - doDeviceLinking = true; - break; - default: - break; - } - return doDeviceLinking; - } - } - // Determine if we have any dependencies that require // us to do a device link step const std::string cuda_lang("CUDA"); cmGeneratorTarget::LinkClosure const* closure = target.GetLinkClosure(config); - bool closureHasCUDA = (std::find(closure->Languages.begin(), closure->Languages.end(), cuda_lang) != closure->Languages.end()); + if (closureHasCUDA) { + if (const char* separableCompilation = + target.GetProperty("CUDA_SEPARABLE_COMPILATION")) { + if (cmSystemTools::IsOn(separableCompilation)) { + bool doDeviceLinking = false; + switch (target.GetType()) { + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::EXECUTABLE: + doDeviceLinking = true; + break; + default: + break; + } + return doDeviceLinking; + } + } + cmComputeLinkInformation* pcli = target.GetLinkInformation(config); if (pcli) { cmLinkLineDeviceComputer deviceLinkComputer( |