CUDA: don't device link if target has no CUDA usage
requested to merge robertmaynard/cmake:CUDA_SEPARABLE_COMPILATION_requires_cuda_linkage_to_enable_device_linking into master
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 (closed)
Topic-rename: cuda-device-link-only-cuda
Backport: release:HEAD^2
Edited by Brad King