Ninja rule for MS resource compiler has too many double quotes
I'm using CMake 3.9.3 on Window 10 with Visual Studio 2015 Update 3.
I've noticed that when my project has a space in its name, the MS resource compiler fails to compile my project but when I remove the space everything works.
At first I thought it was a pathing problem, maybe some path wasn't getting quoted, instead it's the exact opposite - too many quotes!
Here is the rule generated for Ninja as it pertains to RC (tool paths have been abbreviated).
#############################################
# Rule for compiling RC files.
rule RC_COMPILER__
depfile = $DEP_FILE
deps = gcc
command = "C:/.../cmcldeps.exe" RC $in "$DEP_FILE" $out "Note: including file: " "C:/.../cl.exe" C:\...\rc.exe $DEFINES $INCLUDES $FLAGS /fo$out $in
description = Building RC object $out
Note that $DEP_FILE
is surrounded by double quotes. When my project's name has no spaces the command line looks like this (again, paths are shortened):
"C:/.../cmcldeps.exe" RC C:\...\Resource.rc "src\CMakeFiles\OneWord.dir\Resource.rc.res.d" "src\CMakeFiles\OneWord.dir\Resource.rc.res" "Note: including file: " "C:/.../cl.exe" C:\...\rc.exe -DNDEBUG /fo"src\CMakeFiles\OneWord.dir\Resource.rc.res" C:\...\Resource.rc
When I have a space, CMake correctly surrounds any paths using it with double-quotes. However, As you can see from the rule, $DEP_FILE
is also always surrounded by quotes, this destroys the command line like so:
"C:/.../cmcldeps.exe" RC C:\...\Resource.rc ""src\CMakeFiles\Two Words.dir\Resource.rc.res.d"" "src\CMakeFiles\Two Words.dir\Resource.rc.res" "Note: including file: " "C:/.../cl.exe" C:\...\rc.exe -DNDEBUG /fo"src\CMakeFiles\Two Words.dir\Resource.rc.res" C:\...\Resource.rc
This causes the second parameter to RC to be ""
rather than "src\CMakeFiles\Two Words.dir\Resource.rc.res.d"
I'm currently getting around it by having removed the quotes from around $DEP_FILE
in cmNinjaTargetGenerator.cxx:441
. I'm not sure if that's the right fix, but it unblocks me.
Thank you