CMake 3.19 CMAKE_CUDA_ARCHITECTURES causes compiler detection regression
Starting in CMake 3.19 compiler detection for
CUDA now has different behavior based on the existence of the
CMAKE_CUDA_ARCHITECTURES is specified CMake will now error out when
CMAKE_DETERMINE_COMPILER_ID fails ( via
CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS), this is seems safe but has some un-intended side-effects.
Consider the following project:
cmake_minimum_required(VERSION 3.18) # Emulate a Toolchain file # Validate that CUDA_FLAGS are handled properly # when CMAKE_CUDA_ARCHITECTURES is defined by the user set(CMAKE_CUDA_FLAGS [=[-DVAR="With Spaces"]=]) set(CMAKE_CXX_FLAGS [=[-DVAR="With Spaces"]=]) set(CMAKE_CUDA_ARCHITECTURES 52) project(UserCudaArch CXX CUDA) add_executable(UserCudaArch main.cu)
This project correctly configures with CMake 3.18, but fails with 3.19. If we look at the output logs both
CUDA incorrectly transform
-DVAR="With Spaces" but only
CUDA errors out since
CMAKE_CUDA_ARCHITECTURES has been specified.