Better support for custom commands that generate multiple files needed.

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


Brad King wrote:
> Joseph Wenninger wrote:
> 
>>I haven't looked that deep into cmake yet, but is there a reason, why it 
>>doesn't it just allow multiple OUTPUT parameters ? (OUTPUT xyz OUTPUT 
>>asdf  ....) ?
>>
>>I don't know how portable it is and what happens with parallel builds, but at 
>>least in gnu make you can write eg
>>
>>y.tab.c y.tab.h: myfile.y
>>	yacc -d myfile.y
>>
>>And the it usually works for me if a helper command generates more than one 
>>output file
> 
> 
> There is no reason except that it hasn't been implemented in CMake.  I'm 
> working on it now.  AFAIK this multiple-output syntax works in all makes 
> supported by CMake.  There is also similar support in Visual Studio 
> project files.

There is a problem for Makefiles with parallel builds:

all: out1.txt out2.txt
out1.txt out2.txt: in1.txt in2.txt
         echo "hello" > out1.txt
         echo "world" > out2.txt

is actually equivalent to

all: out1.txt out2.txt
out1.txt: in1.txt in2.txt
         echo "hello" > out1.txt
         echo "world" > out2.txt
out2.txt: in1.txt in2.txt
         echo "hello" > out1.txt
         echo "world" > out2.txt

If both out1.txt and out2.txt are missing then the rules may run in 
parallel.  There is discussion of this problem in the automake info page 
("27.6 Handling Tools that Produce Many Outputs").

However, their proposed solution does not seem to work:

      data.stamp: data.foo data.bar
              @rm -f data.tmp
              @touch data.tmp
              foo data.foo data.bar
              @mv -f data.tmp $@
      data.c data.h data.w data.x: data.stamp
              @if test -f $@; then \
                touch $@; \
              else \
                rm -f data.stamp; \
                $(MAKE) $(AM_MAKEFLAGS) data.stamp; \
              fi

The problem is that this just causes multiple recursive makes to try to 
build data.stamp at the same time.

Does anyone know how this works in the old KDE build system?

-Brad


More information about the Kde-buildsystem mailing list