VS: Improve error message when CUDA MSVS integration is not installed
I usually build on Linux, but have set up a Win10 VM to test-build a CUDA-related repository of mine. I'm using CMake 3.21.4 (the version available via chocolatey).
Now, MSVS 2019 is installed on my VM, and I've also installed CUDA 11.5. I haven't installed its MSVS integration, though: Basically, the driver, the runtime, most of the libraries, the compiler, the include files. And it's all at the default installation location: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\
.
When I run CMake, it is not able to locate it the CUDA installation. I get:
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/CMakeDetermineCompilerId.cmake:462 (message):
No CUDA toolset found.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.21/Modules/CMakeDetermineCompilerId.cmake:6 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.21/Modules/CMakeDetermineCompilerId.cmake:59 (__determine_compiler_id_test)
C:/Program Files/CMake/share/cmake-3.21/Modules/CMakeDetermineCUDACompiler.cmake:283 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:18 (PROJECT)
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/src/cuda-api-wrappers/build/CMakeFiles/CMakeOutput.log".
and the CMakeOutput.log
file only has a single line:
The system is: Windows - 10.0.19043 - AMD64
If I manually try to specify where CUDA should be located, this is what happens:
PS C:\Users\User\src\cuda-api-wrappers> & 'C:\Program Files\CMake\bin\cmake.exe' -B build -S . -G "Visual Studio 16 2019" -T "cuda=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5\"
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
CMake Error at CMakeLists.txt:18 (PROJECT):
Generator
Visual Studio 16 2019
given toolset
cuda=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.5"\
cannot detect Visual Studio integration files in path
C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5"/extras/visual_studio_integration/MSBuildExtensions
so, it looks like CMake needs the MSVS integration of CUDA. Why?