[cmake-developers] [CMake 0013559]: Ninja: Wrong dependency with PCH support

Peter Kümmel syntheticpp at gmx.net
Wed Oct 3 12:56:05 EDT 2012


On 03.10.2012 16:47, Mathias Gaunard wrote:
> On 09/25/2012 03:22 PM, Peter Kümmel wrote:
>> On 25.09.2012 14:53, Mantis Bug Tracker wrote:
>>>
>>> The following issue has been SUBMITTED.
>>> ======================================================================
>>> http://public.kitware.com/Bug/view.php?id=13559
>>> ======================================================================
>>
>> There is the code below in the ninja generator, which doesn't use "real"
>> but "order-only" dependency
>> (order-only dependency: "build when needed, don't rebuild on changes"
>> http://martine.github.com/ninja/manual.html#ref_dependencies)
>>
>> Isn't this wrong at all?
>
> Somewhat related:
>
> Things like the following
>
> add_custom_command(OUTPUT foo2.cpp
>                      COMMAND ${CMAKE_COMMAND} -E copy_if_different
> ${CMAKE_CURRENT_SOURCE_DIR}/foo.cpp ${CMAKE_CURRENT_BINARY_DIR}/foo2.cpp
>                      DEPENDS foo.cpp
>                     )
> set_source_files_properties(foo2.cpp PROPERTIES GENERATED ON)
>
> add_executable(foo foo2.cpp)
>
> Will also add an order-only dependency on the custom command, meaning
> that if foo.cpp changed, we will run the custom command to copy it to
> foo2.cpp, but foo2.cpp won't get recompiled.
>
> Testcase attached, touch foo.cpp and run ninja, foo2.cpp is regenerated
> but not rebuilt.
> Manually setting foo2.cpp to OBJECT_DEPENDS on foo.cpp seems to work
> (change set_source_files_properties line with the commented one in
> testcase), but I don't think this should be necessary.

Using order only dependency looks also wrong here. I've changed it to
the implicit one. But I couldn't reproduce it with your example, foo2.cpp
is always build when foo is was touched.

>
> Maybe changing the GENERATED special case in the generator to use
> implicit dependencies would fix it? I'm not sure.
>
> I ran into this problem because in my PCH setup I need to compile the
> same files with different flags, and thus depend on different PCH files
> for each. Since OBJECT_DEPENDS is fixed for a given file, I have to copy
> the source files like above.
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>



More information about the cmake-developers mailing list