FindCUDAToolkit does not set Visual Studio BuildCustomizations properly when there are two CUDA SDKs installed
OS: Windows 10
CMake version: 3.20
Visual Studio generator: Visual Studio 16 2019
CUDA SDKs: 10.2 and 11.2 installed
Details: I specify CUDA 10.2 like this:
FIND_PACKAGE(CUDAToolkit "10.2" EXACT REQUIRED)
CMake runs without error and it seems to work. CUDAToolkit_VERSION
is 10.2.89, and the CUDA bin dir, include dirs, and library dir all specify version 10.2. But looking at the generated .vcxproj file I see:
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.2.props" />
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.2.targets" />
Those should both be 10.2, not 11.2. Looking at the latest source, I think those values are set here:
https://gitlab.kitware.com/cmake/cmake/-/blob/v3.21.1/Modules/CMakeDetermineCompilerId.cmake#L525
and cuda_tools
comes from CMAKE_VS_PLATFORM_TOOLSET_CUDA
here:
https://gitlab.kitware.com/cmake/cmake/-/blob/v3.21.1/Modules/CMakeDetermineCompilerId.cmake#L499
In CMakeLists.txt I added
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_CUDA: ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
and it showed "11.2" which makes sense. So then I added:
SET(CMAKE_VS_PLATFORM_TOOLSET_CUDA "10.2")
but I still get the 11.2 props and targets in the .vcxproj file.