CUDA: Cannot build simple project when PROMPT contains ANSI escape characters
With the simplest possible CUDA project:
cmake_minimum_required(VERSION 3.14)
project(Foo CXX CUDA)
I get the following error:
VC win64 C:\Users\mfischer\src\tests\cmake-cuda-bug\build$ cmake -GNinja ..
-- The CXX compiler identification is MSVC 19.16.27027.1
-- The CUDA compiler identification is NVIDIA 10.0.130
-- Check for working CXX compiler: C:/distlibs/host/VS/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/distlibs/host/VS/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working CUDA compiler: C:/distlibs/vc2017-win64/cuda/bin/nvcc.exe
-- Check for working CUDA compiler: C:/distlibs/vc2017-win64/cuda/bin/nvcc.exe -- broken
CMake Error at C:/distlibs/host/cmake/share/cmake-3.14/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler
"C:/distlibs/vc2017-win64/cuda/bin/nvcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/mfischer/src/tests/cmake-cuda-bug/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/distlibs/host/ninja/ninja.exe cmTC_887ff
[1/3] Building CUDA object CMakeFiles\cmTC_887ff.dir\main.cu.obj
main.cu
main.cu
[2/3] Linking CUDA executable CMakeFiles\cmTC_887ff.dir\cmake_device_link.obj
main.cu.obj
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib
[3/3] Linking CUDA executable cmTC_887ff.exe
FAILED: cmTC_887ff.exe
cmd.exe /C "cd . && C:\distlibs\host\cmake\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_887ff.dir --rc=C:\distlibs\host\SDK\10\bin\10.0.17763.0\x64\rc.exe --mt=C:\distlibs\host\SDK\10\bin\10.0.17763.0\x64\mt.exe --manifests -- C:\distlibs\host\VS\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_887ff.dir\main.cu.obj CMakeFiles\cmTC_887ff.dir\cmake_device_link.obj /out:cmTC_887ff.exe /implib:cmTC_887ff.lib /pdb:cmTC_887ff.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\distlibs\host\VS\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_887ff.dir\main.cu.obj CMakeFiles\cmTC_887ff.dir\cmake_device_link.obj /out:cmTC_887ff.exe /implib:cmTC_887ff.lib /pdb:cmTC_887ff.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_887ff.dir/intermediate.manifest CMakeFiles\cmTC_887ff.dir/manifest.res" failed (exit code 1120) with the following output:
main.cu.obj : error LNK2019: Verweis auf nicht aufgel÷stes externes Symbol "__cudaRegisterFatBinary" in Funktion ""void __cdecl __nv_cudaEntityRegisterCallback(void * *)" (?__nv_cudaEntityRegisterCallback@@YAXPEAPEAX@Z)".
main.cu.obj : error LNK2019: Verweis auf nicht aufgel÷stes externes Symbol "__cudaUnregisterFatBinary" in Funktion ""void __cdecl __cudaUnregisterBinaryUtil(void)" (?__cudaUnregisterBinaryUtil@@YAXXZ)".
cmTC_887ff.exe : fatal error LNK1120: 2 nicht aufgel÷ste Externe
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/mfischer/src/tests/cmake-cuda-bug/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/mfischer/src/tests/cmake-cuda-bug/build/CMakeFiles/CMakeError.log".
This is with the following tools:
$ cmake --version
cmake version 3.14.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
$ cl
Microsoft (R) C/C++-Optimierungscompiler Version 19.16.27027.1 für x64
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
Syntax: cl [ Option... ] Dateiname... [ /link Linkeroption... ]
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130
$ cmake -GNinja --debug-trycompile ..
...
$ nvcc --run CMakeFiles\CMakeTmp\main.cu
works fine...
Edited by Mika Fischer