How to get CMake Cuda project working with Visual Studio 2022

Louis Child 0 Reputation points
2024-12-05T15:27:50.4566667+00:00

I have a sample project that demonstrates setting up a Cuda project with CMake and Conan as a dependency manager. Using VSCode and Linux, this works exactly as expected and you can build and debug Cuda code, including kernels, as well has full IntelliSense support.

Using CMake with Cuda doesn't work for Visual Studio. I have tried using CMake to generate a Visual Studio 2022 project. But when that project is opened there is no IntelliSense support, it is unable to resolve any symbols, and all the Cuda API functions are marked as errors. Because of this, even though you can build the project, debugging Cuda kernels is impossible.

I also tried opening the project directly via the CMakeLists and that resulted in Visual Studio unable to find the toolchain files, even though they were present on disk. I managed to get the toolchain file issues resolved by moving the files around but all the errors with the Visual Studio 2022 project were still preset.

How is it possible to have a valid working, debuggable project developed from a CMake file

I am using Visual Studio 2022 version 17.12.2 and the Nvidia Visual Studio Edition 2024.3.0 on Windows 11 with Cuda SDK 12.6

Developer technologies | Visual Studio | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.