Skip to content

CUDA: Fix CUDA_ARCHITECTURES policy CMP0104 check in try_compile

Brad King requested to merge brad.king/cmake:cuda-arch-cmp0104 into master

Since !4568 (merged), CMAKE_CUDA_ARCHITECTURES is both initialized and required by policy CMP0104's NEW behavior. Inside a try_compile project we use cmake_minimum_required(VERSION ...) with the current running version of CMake. Now that our version number is 3.18, CMP0104 gets set to NEW in the try_compile. If the outer projects does not set the policy then CMAKE_CUDA_ARCHITECTURES is not available and the try_compile fails to generate.

Teach try_compile to check the outer project's policy status and set policy CMP0104 to OLD if needed to match.

Fixes: #20794 (closed)
Backport: release

Merge request reports