CUDA: custom build error with "CMake error: Error processing file: ..."
Build servers of our CI system sometimes produce some error messages like below.
...
12:29:24,609 INFO - Building NVCC (Device) object test/snx3sdk/testCUDA11/CMakeFiles/testCUDA11.dir/__/__/__/__/__/__/scanvision/test/testCUDA/kernalLaunch/Release/testCUDA11_generated_testCUDAKernelLaunch.cu.obj
12:29:24,609 INFO - CMake Error in testCUDA11_generated_testCUDAKernelLaunch.cu.obj.Release.cmake:
12:29:24,609 INFO - cmListFileCache: error can not open file.
12:29:24,609 INFO -
12:29:24,609 INFO -
12:29:24,609 INFO - CUSTOMBUILD : CMake error : Error processing file: C:/Workspace_Git/desktop-app/kernel/release/1.4/
package/kernel/_intermediate/build/kernel-vs2019/test/snx3sdk/testCUDA11/CMakeFiles/testCUDA11.dir/__/__/__/__/__/__/scanvision/
test/testCUDA/kernalLaunch/testCUDA11_generated_testCUDAKernelLaunch.cu.obj.Release.cmake [C:\Workspace_Git\desktop-app\
kernel\release\1.4\package\kernel\_intermediate\build\kernel-vs2019\test\snx3sdk\testCUDA11\testCUDA11.vcxproj]
12:29:24,609 INFO - C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\
VC\v160\Microsoft.CppCommon.targets(238,5):do_not_litter: error MSB8066: Custom build for '..\..\..\..\..\..\scanvision\
test\testCUDA\kernalLaunch\testCUDAKernelLaunch.cu' exited with code 1. [C:\Workspace_Git\desktop-app\
kernel\release\1.4\package\kernel\_intermediate\build\kernel-vs2019\test\snx3sdk\testCUDA11\testCUDA11.vcxproj]
12:29:24,609 INFO - CMake Error in testCUDA10_generated_testCUDAKernelLaunch.cu.obj.Release.cmake:
12:29:24,609 INFO - cmListFileCache: error can not open file.
12:29:24,609 INFO -
12:29:24,609 INFO -
...
I suppose that there seems to be a trouble running NVCC through CMake. Here is the "Custom Build Tools/Command Line" setting of the problem .cu file in the above error message.
...
C:\Workspace_Git\desktop-app\kernel\release\1.4\package\kernel\build\marc\tools\cmake\cmake-3.16.4-windows64\bin\cmake.exe
-D verbose:BOOL=ON -D "CCBIN:PATH=$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)"
-D build_configuration:STRING=$(ConfigurationName) -D generated_file:STRING=C:/Workspace_Git/desktop-app/kernel/release/1.4/
package/kernel/_intermediate/build/kernel-vs2019/test/snx3sdk/testCUDA11/CMakeFiles/testCUDA11.dir/__/__/__/__/__/__/scanvision/
test/testCUDA/kernalLaunch/$(Configuration)/testCUDA11_generated_testCUDAKernelLaunch.cu.obj
-D generated_cubin_file:STRING=C:/Workspace_Git/desktop-app/kernel/release/1.4/package/kernel/_intermediate/build/
kernel-vs2019/test/snx3sdk/testCUDA11/CMakeFiles/testCUDA11.dir/__/__/__/__/__/__/scanvision/
test/testCUDA/kernalLaunch/$(Configuration)/testCUDA11_generated_testCUDAKernelLaunch.cu.obj.cubin.txt
-P C:/Workspace_Git/desktop-app/kernel/release/1.4/package/kernel/_intermediate/build/kernel-vs2019/test/
snx3sdk/testCUDA11/CMakeFiles/testCUDA11.dir/__/__/__/__/__/__/scanvision/test/testCUDA/kernalLaunch/
testCUDA11_generated_testCUDAKernelLaunch.cu.obj.Release.cmake
...
FYI, our CI's proof-build system checks out a Git repository to a path that includes the branch name, and sometimes creating files with path lengths of 260 characters or more. In order to handle these files with long path lengths, we have changed the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathEnabled
from 0
to 1
in the Windows registry. In this case, files with more than 260 characters are not a problem in the typical build process, except when running NVCC through CMake. So I suspect that CMake.exe cannot process if the file path name input through the CLI exceeds 260 characters regardless of the Windows maximum path length setting.