[cmake-developers] ninja enforces explicit dependencies before order-only

Brad King brad.king at kitware.com
Thu Apr 4 08:20:10 EDT 2013


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



More information about the cmake-developers mailing list