[CMake] Parallel builds do not work correctly when using "cmake -E copy" to copy files

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Dec 13 18:59:50 EST 2007


On 2007-12-13 17:07-0500 Brad King wrote:

> Alan W. Irwin wrote:
>> So just keeping narrowly focussed on that fragment there is only one "ALL"
>> custom target and ADD_DEPENDENCIES would not help since it only works on
>> targets.  Thus, I doubt there is anything locally wrong with dependencies
>> there.  It is possible some other dependency is making a dependency pattern
>> that triggers the bug, but I should know more about that when I have a
>> simpler example that triggers the bug (or not).
>
> I was able to reproduce the problem with the code below.  It is fixed by
> uncommenting the ADD_DEPENDENCIES line.  You must be putting those
> output files into another target that does not depend on the
> tcl_examples target.  Perhaps the make_documentation target?
>
> -Brad
>
>
> PROJECT(FOO)
>
> FOREACH(f f1 f2 f3 f4 f5 f6 f7 f8 f9)
>  LIST(APPEND DEPS ${FOO_BINARY_DIR}/${f})
>  ADD_CUSTOM_COMMAND(OUTPUT ${FOO_BINARY_DIR}/${f}
>    COMMAND echo ${f} > ${FOO_BINARY_DIR}/${f}
>    )
> ENDFOREACH(f)
> ADD_CUSTOM_TARGET(examples ALL DEPENDS ${DEPS})
> ADD_CUSTOM_TARGET(examples2 ALL DEPENDS ${DEPS})
> #ADD_DEPENDENCIES(examples2 examples)

Good example, Brad!

Working from the PLplot case, I came up with another simple test case
(complete tarball attached including the required small files to be copied
for those who want to play with it).

In the PLplot case (and also the attached simple test case) there is
an additional custom command that file depends on the copied files.  In
addition there is a custom target that depends on the additional custom
command output file, and a custom target that depends on the copied files.

So the rule seems to be that parallel builds do not work if there are two
or more separate custom targets that file depend directly or indirectly (via
some custom command file dependency chain) on the same output files.

Another way of summarizing these results is that file depends must be
minimized and/or custom target depends maximized in order for parallel
builds to work properly.

My guess is I should be able to work around this CMake issue by appropriate
changes to the PLplot build system although I have a number of these
parallel build issues and the copy problem was only the most obvious.

I do regard this as a CMake issue.  Normally, the shoe is on the other foot,
and the build system developer is desperately trying to make sure that all
the CMake file depends are obviously in place locally rather than depending
on a long easily-broken chain of dependencies to do it for them in a
minimalist way.  So the big question is whether CMake can be modified so
that minimalist file depends and/or maximal (and unintuitive) target depends
are not required in order for parallel builds to work properly.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_parallel.tar.gz
Type: application/octet-stream
Size: 1250 bytes
Desc: complete CMake test case for bad parallel builds
Url : http://public.kitware.com/pipermail/cmake/attachments/20071213/745f9506/test_parallel.tar.obj


More information about the CMake mailing list