Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On 04/04/2013 09:45 AM, Robert Maynard wrote: > My current work in progress on this problem can be found To follow up on this, I've just merged a topic Robert implemented (to add the phony rules) to master: http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=539356f1 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=874e1712 -Brad -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
My current work in progress on this problem can be found at: https://github.com/robertmaynard/CMake/tree/ninja_phony_file_targets On Thu, Apr 4, 2013 at 8:20 AM, Brad King wrote: > On 04/04/2013 07:57 AM, Peter Kümmel wrote: > > On 02.04.2013 15:19, Brad King wrote: > >> build libA.a: C_STATIC_LIBRARY_LINKER CMakeFiles/A.dir/a.c.o > >> POST_BUILD = cd ".../build" && cp .../a.c a.txt > > > > In build.ninja is no rule for coping a.c to a.txt at all. > > Seems support for add_custom_command(TARGET) is missing or broken. > > No, the CMakeLists.txt code I posted does not even tell CMake > that any particular rule generates a.txt. The expectation is > that by the time the rules for CMake target B are evaluated the > file will have been created due to the order-dependency of B on A. > > All the other (Makefiles, VS, Xcode) produce build systems that > evaluate file-level dependencies inside each main CMake target > separately. Ninja has a monolithic file so it needs additional > work to achieve this. The solution Robert proposed is to add > rules like > > build a.txt : phony a.txt > > for all the file-level dependencies located in the build tree > for which there is no custom command output. That may convince > Ninja to skip complaining about the missing explicit dependency. > > -Brad > -- > > 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 > -- Robert Maynard -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On 04/04/2013 07:57 AM, Peter Kümmel wrote: > On 02.04.2013 15:19, Brad King wrote: >> build libA.a: C_STATIC_LIBRARY_LINKER CMakeFiles/A.dir/a.c.o >> POST_BUILD = cd ".../build" && cp .../a.c a.txt > > In build.ninja is no rule for coping a.c to a.txt at all. > Seems support for add_custom_command(TARGET) is missing or broken. No, the CMakeLists.txt code I posted does not even tell CMake that any particular rule generates a.txt. The expectation is that by the time the rules for CMake target B are evaluated the file will have been created due to the order-dependency of B on A. All the other (Makefiles, VS, Xcode) produce build systems that evaluate file-level dependencies inside each main CMake target separately. Ninja has a monolithic file so it needs additional work to achieve this. The solution Robert proposed is to add rules like build a.txt : phony a.txt for all the file-level dependencies located in the build tree for which there is no custom command output. That may convince Ninja to skip complaining about the missing explicit dependency. -Brad -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On 02.04.2013 15:19, Brad King wrote: Hi Peter, We've come across a case where the Makefile, VS, and Xcode generators work but Ninja does not:: cmake_minimum_required(VERSION 2.8.10) project(DependSideEffect C) add_library(A a.c) add_custom_command( TARGET A POST_BUILD COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/a.c a.txt ) add_custom_command( OUTPUT b.txt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/a.txt COMMAND cp a.txt b.txt ) add_custom_target(B ALL DEPENDS b.txt) add_dependencies(B A) CMake's rule for target-level dependencies is that "A" must be up to date before the build system evaluates the rules of "B". Building with Ninja fails with:: ninja: error: 'a.txt', needed by 'b.txt', missing and no known rule to make it Relevant portions of build.ninja:: build libA.a: C_STATIC_LIBRARY_LINKER CMakeFiles/A.dir/a.c.o POST_BUILD = cd ".../build" && cp .../a.c a.txt ... build b.txt: CUSTOM_COMMAND a.txt || libA.a COMMAND = cd ".../build" && cp a.txt b.txt ... The rule for "b.txt" has an order-only dependency on "libA.a" and an explicit dependency on "a.txt". Ninja does not wait for the order-only dependencies to be up to date before complaining that the explicit dependency is missing. Can ninja be taught to wait for order-only dependencies to be up to date to see if they produce any of the explicit dependencies as a side effect? Is there another way to do this in CMake's Ninja gen? Thanks, -Brad In build.ninja is no rule for coping a.c to a.txt at all. Seems support for add_custom_command(TARGET) is missing or broken. Could you open a ticket and assign to me? Peter -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On Tue, Apr 2, 2013 at 9:19 AM, Brad King wrote: > ... > a side effect? Is there another way to do this in CMake's Ninja gen? > Yes I have found a way we can do this in CMake's Ninja generator. The Ninja generator needs to be taught to create phony ninja targets for any file that exists in the build directory and which is a dependency of a custom command target ( this might need to be expanded to a dependency of any target in the future). Ninja phony targets can also be used to create targets for files which may not exist at build time otherwise an error will occur if the file does not exist. I hope to have a branch by the end of this week that will update the Ninja generator with this fix. -- Robert Maynard -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On 04/02/2013 11:35 AM, Matthew Woehlke wrote: > Why are the rules set up like this and not such that b.txt depends on A? A and B are separate CMake logical targets. There is no concept in CMake of a file depending on a logical target. There is no way to express that in the generated VS or Makefile build systems. > I'm not convinced this is a bug It works in all generators except Ninja. Therefore it is at least a bug in CMake's Ninja generator by not finding a way to implement the desired behavior with its native build system. If it is not possible to implement the behavior in Ninja then that is a missing feature. Think of each CMake logical target as its own isolated make process. Evaluation of a dependent target does not even start until after its dependencies have finished. In the example I posted target "B" has no rule to build file "a.txt" so it assumes that the file always exists as if it were a source file. The assumption is valid because target B should not be evaluated until target A is done. We need a way to implement this with Ninja. -Brad -- 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
Re: [cmake-developers] ninja enforces explicit dependencies before order-only
On 2013-04-02 09:19, Brad King wrote: Hi Peter, We've come across a case where the Makefile, VS, and Xcode generators work but Ninja does not:: cmake_minimum_required(VERSION 2.8.10) project(DependSideEffect C) add_library(A a.c) add_custom_command( TARGET A POST_BUILD COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/a.c a.txt ) add_custom_command( OUTPUT b.txt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/a.txt COMMAND cp a.txt b.txt ) add_custom_target(B ALL DEPENDS b.txt) add_dependencies(B A) CMake's rule for target-level dependencies is that "A" must be up to date before the build system evaluates the rules of "B". Building with Ninja fails with:: ninja: error: 'a.txt', needed by 'b.txt', missing and no known rule to make it Relevant portions of build.ninja:: build libA.a: C_STATIC_LIBRARY_LINKER CMakeFiles/A.dir/a.c.o POST_BUILD = cd ".../build" && cp .../a.c a.txt ... build b.txt: CUSTOM_COMMAND a.txt || libA.a COMMAND = cd ".../build" && cp a.txt b.txt ... The rule for "b.txt" has an order-only dependency on "libA.a" and an explicit dependency on "a.txt". Ninja does not wait for the order-only dependencies to be up to date before complaining that the explicit dependency is missing. Can ninja be taught to wait for order-only dependencies to be up to date to see if they produce any of the explicit dependencies as a side effect? Is there another way to do this in CMake's Ninja gen? Why are the rules set up like this and not such that b.txt depends on A? I'm not convinced this is a bug; In the absence of a custom command having an 'OUTPUT a.txt', there is no expression that the custom command for b.txt depends on any build rule. IMHO what ninja is doing is perfectly justifiable behavior for the build rules given above. If I were to hand-write a Makefile from the above, I would come up with something like: a.o: a.c A: a.o cp a.c ${build}/b.txt b.txt: ${build}/a.txt cp a.txt b.txt B: A b.txt Note that there is nothing in the dependency graph of the above which requires that the build system must build A before b.txt. -- Matthew -- 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