CMake flags to rc are incompatible with llvm-rc
This issue is migrated from #18745 (comment 520491)
The issue/merge there made it so that CMake respects the setting of CMAKE_RC_COMPILER
such that, for example, llvm-rc
can be used. However the flags passed are incompatible with llvm-rc
:
-- The CXX compiler identification is Clang 7.0.1
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- broken
CMake Error at cmake-3-14/cmake-3.14.0-rc2-win64-x64/share/cmake-3.14/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files/LLVM/bin/clang-cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/a/1/s/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/ProgramData/chocolatey/bin/ninja.exe cmTC_21ab3
[1/2] Building CXX object CMakeFiles\cmTC_21ab3.dir\testCXXCompiler.cxx.obj
[2/2] Linking CXX executable cmTC_21ab3.exe
FAILED: cmTC_21ab3.exe
cmd.exe /C "cd . && D:\a\1\s\cmake-3-14\cmake-3.14.0-rc2-win64-x64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_21ab3.dir --rc=llvm-rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\LLVM\bin\lld-link.exe /nologo CMakeFiles\cmTC_21ab3.dir\testCXXCompiler.cxx.obj /out:cmTC_21ab3.exe /implib:cmTC_21ab3.lib /pdb:cmTC_21ab3.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 ."
RC Pass 1: command "llvm-rc /foCMakeFiles\cmTC_21ab3.dir/manifest.res CMakeFiles\cmTC_21ab3.dir/manifest.rc" failed (exit code 1) with the following output:
Exactly one input file should be provided.
ninja: build stopped: subcommand failed.
Looking at cmcmd.cxx
it seems that "/fo"
is always used to specify the desired name for the output .res
file. This works fine for Windows rc.exe
but with llvm-rc.exe
(I'm using 7.0.1) there needs to be a space between /fo
and the desired output filename.
Some local experimenting with rc.exe
and llvm-rc.exe
shows that /fo argument.res
works for both so this may be a one-character fix