[CMake] Ninja order-only dependency makes inefficient ninja DAG

Kristofer Tingdahl kristofer.tingdahl at dgbes.com
Wed Jun 18 04:13:15 EDT 2014


Hi,

CMake adds order-only dependencies in build.ninja between libraries and
subsequent object-files, and I cannot see why this is needed. Consider the
following CMakeLists.txt:

project( program )
add_library( A SHARED a.cc )
add_library( B SHARED b.cc )
target_link_libraries( B A )
add_executable( prog program.cc )
target_link_libraries( prog B )

There are a couple of targets generated:
a.cc.o, b.cc.o, libA.so, libB.so, prog.cc.o and prog.

The ninja-file will make these targets be built in the following steps:

   1. a.cc.o
   2. libA.so
   3. b.cc.o
   4. libB.so
   5. prog.cc.o
   6. prog


My point is that there is no reason to wait building b.cc.o and prog.cc.o;
they can be built at the same time as a.cc.o .

Hence I wonder why libA.so is added as a order-only dependency to b.cc.o
when CMake processes this? If there is no good reason, can I avoid it by
changing the CMakeLists.txt (perhaps with a variable)? If that is not
possible, would the cmake-team be interested if I dive into it and make a
patch?

Any thought is welcome!

Cheers,

Kristofer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140618/abddcae5/attachment.html>


More information about the CMake mailing list