[cmake-developers] ninja bug on windows

Peter Collingbourne peter at pcc.me.uk
Tue Mar 13 22:39:37 EDT 2012


On Tue, Mar 13, 2012 at 07:08:31PM -0400, Bill Hoffman wrote:
> PrecompiledHeader - This one seems to be a dependency problem.
>
> The first time you run it you get this:
>
> 122: Run Build Command:C:/cygwin/bin/ninja.exe
> [3/4] Building C object CMakeFiles\foo.dir\foo1.c.obj
> 122: FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\cl.exe   /nologo /DWIN32  
> /D_WINDOWS /W3 /Zm1000 /D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1  
> /Yufoo_precompiled.h /FIfoo_precompiled.h "/FpC:/Users/hoffman/Work/My  
> Builds/cmake-ninja/Tests/PrecompiledHeader/PCH/foo_precompiled.pch"  
> /FoCMakeFiles\foo.dir\foo1.c.obj /Fdfoo.pdb -c "C:\Users\hoffman\Work\My  
> Builds\cmake\Tests\PrecompiledHeader\foo1.c"
> 122:
> 122: foo1.c
> 122: C:\Users\hoffman\Work\My  
> Builds\cmake\Tests\PrecompiledHeader\foo1.c : fatal error C1083: Cannot  
> open precompiled header file: 'C:/Users/hoffman/Work/My  
> Builds/cmake-ninja/Tests/PrecompiledHeader/PCH/foo_precompiled.pch':  
> Permission denied
> [3/4] Building C object CMakeFiles\foo.dir\foo_precompile.c.obj  out:  
> foo_precom[3/4] Building C object CMakeFiles\foo.dir\foo2.c.obj           
>                 out: foo2.c
> 122: ninja: build stopped: subcommand failed.
> 1/1 Test #122: PrecompiledHeader ................***Failed    1.96 sec
>
> If I run the test again, it passes.   Might be that ninja is doing more  
> in parallel than gmake, nmake or visual studio.

Yes, it is a dependency problem.  Neither the Makefile nor Ninja
generators can easily generate correct dependencies for PCH,
because the PCH output file name only appears in the compiler flags.
The CMakeLists.txt for this test contains a hack to add correct
dependency information for the Makefile generator:

> # Setup dependencies for precompiled header creation and use.  The VS
> # IDE takes care of this automatically.
> IF("${CMAKE_GENERATOR}" MATCHES "Makefile")
>   # This source file creates the precompiled header as a side-effect.
>   SET_SOURCE_FILES_PROPERTIES(foo_precompile.c PROPERTIES
>     OBJECT_OUTPUTS "${PCH_DIR}/foo_precompiled.pch")
> 
>   # These source files use the precompiled header.
>   SET_SOURCE_FILES_PROPERTIES(${foo_SRCS} PROPERTIES
>     OBJECT_DEPENDS "${PCH_DIR}/foo_precompiled.pch")
> ENDIF("${CMAKE_GENERATOR}" MATCHES "Makefile")

Maybe another time we can think about ways to improve PCH support,
but for now I guess we can add an OR Ninja to this test and add
OBJECT_OUTPUTS support to the Ninja generator.

Thanks,
-- 
Peter


More information about the cmake-developers mailing list