Nvcc.exe Fails to use -I"Some Include Directory" correctly

What is the proper way to construct a CMake to generate CUDA projects that leverage third-party dependencies?

System Info:
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.7.4
CMake 3.27.4

Error Information
“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\nvcc.exe” --use-local-env -ccbin
“C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64” -x cu

(Note: Full path here is -I"C:\test\Documents\Dev\GitHub\temp\clutter_patch_temp_build_deps\efftw-src\include\efftw") therefore the ‘#include<efftw/efftw.hpp>’ was expected to be found, but is not)

-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include"
–keep-dir x64\Debug -maxrregcount=0
–machine 64 --compile -cudart static -std=c++20
–generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler=“/EHsc -Zi -Ob0” -g
-DWINDOWS_OS -D"CMAKE_INTDIR="Debug"" -Xcompiler "/EHsc /W1 /nologo /Od /FS /Zi /RTC1 /MTd "
-Xcompiler “/Fdnvidia_cuda_test.dir\Debug\vc143.pdb” -o nvidia_cuda_test.dir\Debug/nvidia_cuda_test.cu.obj

fatal error C1083: Cannot open include file: ‘efftw/efftw.hpp’: No such file or directory

1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.2.targets(799,9):
error MSB3721: The command "“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\nvcc.exe” --use-local-env -ccbin
1>Done building project “nvidia_cuda_test.vcxproj” – FAILED.

What is the proper way to construct a CMake to generate CUDA projects that leverage third-party dependencies?

I don’t really see a problem with what you have. I am not a CMake expert, but the console output you have doesn’t really depend on CMake for interpretation. The include directory appears to be specified correctly. There isn’t any alternate method or defect there that I can see. The conclusion I would start with (not certain, just a starting point) is that the error given by the compiler:

is legit, and that file is actually not there. Naturally I don’t have your machine in front of me, and I’m sure you dispute this theory, otherwise you wouldn’t have posted here, but it might be worth rechecking. Make sure the actual file (name) and path doesn’t have any unusual or hidden characters in it. Sometime people intend that you only include a .h file even in a CPP project, and then have that .h file include a corresponding .hpp file if cpp compilation is detected.

You might wish to run some experiments renaming the file in question, and moving to alternate paths and changing your include path definition, to see if you can learn anything.

The specified include path already ends in efftw, so the #include statement should probably be #include <efftw.hpp>. Right now the compilation would be looking for:


In other words, the path component efftw will appear twice, which is probably not what was intended. Mixing of path separators slash and backslash may also not be supported; the backslash is the separator native to Windows.

I would suggest using #include <efftw.hpp> (that is, file name only) in the code, and specifying the path for the -I switch accordingly.

I think this is the specified include path, from the perspective of nvcc compilation command:

@Robert_Crovella You are correct, my eyes skipped from the line with the actual -I specification to the next line as I was scanning through it. Looking for my reading glasses now …