Reputation: 2223
I have a very simple CUDA project:
cmake_minimum_required(VERSION 3.17)
project(simpleCuda LANGUAGES CXX CUDA)
add_executable(simpleCuda)
target_sources(simpleCuda PUBLIC main.cu)
target_compile_features(simpleCuda PUBLIC cxx_std_17)
I can open that folder and build/run the executable just fine. However, all the CUDA intellisense is messed up (__global__
, cudaMalloc
, etc.). Am I missing something? See my CMakeSettings.json
below
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [],
"intelliSenseMode": "windows-msvc-x64"
}
]
}
and the CMake target view:
Note that the intellisense for C++ is also messed up. I don't get any auto-completetion.
Upvotes: 1
Views: 1089
Reputation: 23808
Intellisense not working for CMake CUDA project in Visual Studio 2019
I think you should use add include_directories("xxxx"//contain the CUDA library path)
in CMakeLists.txt
file to include CUDA library for Intellisense.
Add this in every CMakeLists.txt
file:
include_directories("C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include")
Besides, if it still does not work, please these steps:
1) close VS, delete .vs
hidden folder under the solution folder and any output folders like out
and then restart your project to test again.
2) disable any other third party vs extensions under Extensions menu-->Manage Extensions to check whether it is caused by some extensions.
3) reset all vs settings by Tools-->Import and Export Settings->Reset All settings
4) do a repair in VS or update it to the latest version
Upvotes: 1