MSVC prints a blank line there, and it turns out CMake (at least currently released versions) expects it to be there.
Diff Detail
Event Timeline
lib/Frontend/HeaderIncludeGen.cpp | ||
---|---|---|
106 | Doesn't do that for me: C:\src\ninja>cl /c test.cc /nologo /showIncludes |
I do not think MSVC starts off with an empty line with -showIncludes specifically. It is just that MSVC unconditionally prints the name of the source file first. This means that any showIncludes output is naturally preceded by a newline because at least one other line was printed first. If clang-cl is to have compatible output with MS cl then it should print the source file name first too. However, that would be a broader decision that should stand on its own.
IMO the motivating use case is simply a bug in CMake and clang-cl should not have to adapt to it. There is already a workaround available for existing clang-cl/CMake release combinations. CMake nightly binaries will be available starting tonight with the fix, and the CMake 3.6 release will have the fix too.
lib/Frontend/HeaderIncludeGen.cpp | ||
---|---|---|
106 | Ah, it's the newline after "test.cc" that CMake looks for. Hmm.. |
I agree with Brad that it'd be nice if we didn't have to add this :-)
What's the workaround for current cmake releases?
Passing -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " is the work-around I used.
I just figured that if this is easy to fix, it would be nice for clang-cl users who don't have a bleeding-edge CMake version.
So ninja knows how to filter out the source line that cl.exe prints unconditionally, without a way to disable that. If you add a bare newline, ninja won't filter that out and this will add an empty line to each compile step run under ninja. To work around that, you could print the source input file, but that seems very undesirable.
So I think doing nothing (and documenting the workaround somewhere) is probably the best path forward :-/
(Also, this "only" affects .rc compilations, not regular source compilations -- those don't go through cmcldeps)
Printing the source input file would be fiddly, and since this doesn't seem to have bitten a lot of people yet, I suppose it's not worth pursuing further.
Doesn't do that for me:
C:\src\ninja>cl /c test.cc /nologo /showIncludes
test.cc
Note: including file: c:\src\ninja\test.h