NVCC options file encoded with BOM causes the "single input file is required" error
Bug reproduction
Environment
NVCC compiler:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Mon_Oct_24_19:40:05_Pacific_Daylight_Time_2022
Cuda compilation tools, release 12.0, V12.0.76
Build cuda_12.0.r12.0/compiler.31968024_0
Windows, MSVC and nmake.
Affected CMake versions: 3.25.2, 3.26.0-rc3
Files
CMakeLists.txt
:
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
project(test LANGUAGES CUDA)
add_executable(test main.cu)
target_include_directories(test PRIVATE "include")
main.cu
:
#include "header.hh"
int main() { return 0; }
include/header.hh
:
#pragma once
#define HELLO 1
Steps
cmake -G "NMake Makefiles" .
nmake
Output
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
NMAKE : fatal error U1077: '"E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.0\bin\nvcc.exe" -forward-unknown-to-host-compiler --options-file CMakeFiles/test.dir/includes_CUDA.rsp -D_WINDOWS -Xcompiler=" /EHsc" -Xcompiler=" -Ob0 -Od /RTC1" --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler=-MDd -Xcompiler=-Zi -MD -MT CMakeFiles\test.dir\main.cu.obj -MF CMakeFiles\test.dir\main.cu.obj.d -x cu -c D:\dev\cmake-bom\main.cu -o CMakeFiles\test.dir\main.cu.obj -Xcompiler=-FdCMakeFiles\test.dir\,-FS' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\test.dir\build.make /nologo -SL CMakeFiles\test.dir\build' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX64\x64\nmake.exe" -s -f CMakeFiles\Makefile2 /nologo -S all' : return code '0x2'
Stop.
Culprit
- File:
CMakeFiles/test.dir/includes_CUDA.rsp
- Contents:
-I"D:/dev/cmake-bom/include"
- Encoding: UTF-8 with BOM
Temporary fix
- Save the file without BOM
End
Please fix. Thanks!