Dims
Dims

Reputation: 51039

CMake uses too long paths when searching for CUDA compiler on Windows

I am running CMake from under CLion and when identifying CUDA compiler, it apperently uses too long paths, and fails (according to CMakeError.log file):

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/bin/nvcc.exe 
Build flags: 
Id flags: --keep;--keep-dir;tmp -v

The output was:
1

D:\TESTS\CUDA_CLion\test01\cmake-build-debug\CMakeFiles\3.19.1\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat" 
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal   : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
...

The command it runs is (according to CMake pane of CLion):

D:\Apps\CMake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug --debug-output -G "CodeBlocks - NMake Makefiles" D:\TESTS\CUDA_CLion\test01

If I run this command from CLI, it also fails, but with different error:

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/bin/nvcc.exe 
Build flags: 
Id flags: --keep;--keep-dir;tmp -v

The output was:
1
nvcc fatal   : Cannot find compiler 'cl.exe' in PATH

And finally, if I just run

cmake ..

from CLI it works: it finds itself Ok with long paths, it finds cl.exe, everything.

The question is: how to fix everything OR how to force CLion just to use only CMake without imagination?

Upvotes: 1

Views: 815

Answers (1)

Yi Zhang
Yi Zhang

Reputation: 297

Did your script invoke vcvarsall.bat or vcvars64.bat multiple times? It could be solved by reduce them

Upvotes: 1

Related Questions