Skip to content

VS: Don't compute CUDA options unless necessary

Raul Tambre requested to merge tambre/cmake:cuda_vs_skip_computation into master

In the following scenario (with 3.18 policies):

  1. A CXX target is created.
  2. CUDA language is enabled.

CMake 3.18 introduced CMP0104, which requires CUDA_ARCHITECTURES to be set. Because the CXX target was created before CUDA was enabled it wouldn't have it set. The Visual Studio generator would however end up computing CUDA compile options for the CXX target, which would result in a fatal error due to the policy violation.

There doesn't seem to be a reason to do the computation for targets that don't actually use the CUDA language, so we can skip and generate the CXX target just fine.

Fixes: #21341 (closed)
Backport: release

Edited by Brad King

Merge request reports