I've been trying to address the following issue in clangd for Visual Studio Code trying to access CUDA:
https://github.com/clangd/clangd/issues/793
This patch alone is not yet sufficient for a fully functional clangd, but it gets rid of the error message saying
Cannot find CUDA installation. Provide its path via --cuda-path, or pass -nocudainc to build without CUDA includes.
in case clangd and the code is located on the C: drive.
In my case I had both clangd (which I needed for debugging purposes) and the source code on D:. At this point:
Candidates.emplace_back(D.SysRoot + "/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" + Ver);
the D.SysRoot seems to be empty. Then, during the call to
if (InstallPath.empty() || !FS.exists(InstallPath))
after sys::fs::make_absolute(WD->Resolved, Storage); (in VirtualFileSystem.cpp) the Storage expands to D:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4 which isn't found either.
looks like the list is getting big and hard to maintain. considering that this is done only once per compiler invocation (and we check for existence of directories down in the loop anyway). what about throwing in an extra directory listing to base-directories mentioned down below and populate Candidates while preserving the newest-version-first order?