Better support for custom commands that generate multiple files needed.

Brad King brad.king at kitware.com
Fri Apr 7 23:47:23 CEST 2006


David Faure wrote:
> On Friday 07 April 2006 23:17, Brad King wrote:
> 
>>Does anyone know how this works in the old KDE build system?
> 
> 
> We had this, and I think it's correct:
> 
> field.cpp: addressee.h addressee.cpp
> addressee.cpp: addressee.h
> addressee.cpp addressee.h field.cpp: [...dependencies...]
>         mysrcdir=`cd $(srcdir)/scripts && pwd` ;\
>         cd scripts && $(PERL) $$mysrcdir/makeaddressee
> 
> I.e. add "out1.txt: out2txt" to your example (or the other way round), so that only one 
> of the generated files is rebuilt at a given moment, instead of both of them at the same time.

This requires knowledge of the order in which the outputs are generated 
and how their timestams will appear on disk.  I suppose we could require 
the user to specify the outputs in order but that will be error prone.

I've found a solution:

all: check_build_system
         @$(MAKE) out1.txt out2.txt
out1.txt: in1.txt in2.txt
         echo "hello" > out1.txt
         echo "world" > out2.txt
out2.txt: out1.txt

check_build_system:
         @if [ ! -f "out2.txt" ]; then rm -f out1.txt; fi

There is already a "cmake_check_build_system" step that runs CMake at 
the beginning of the build anyway.  We can add the if/rm code in C++ in 
that CMake checking step.

-Brad


More information about the Kde-buildsystem mailing list