[CMake] Re-executing the make command with few or no source tree changes is extremely inefficient for CMake-2.4.3

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Aug 17 14:46:36 EDT 2006


On 2006-08-17 13:53-0400 Brad King wrote:

> [out of order] You need to use ADD_CUSTOM_COMMAND.

That may be another alternative to ADD_CUSTOM_TARGET, but I don't think it
is possible since I need a target I can refer to in parallel directories
(not below the directory where plhershey-unicode.h gets built). I have never
been able to get dependencies to work across directories for the
ADD_CUSTOM_COMMAND, but they do work across directories for the
ADD_CUSTOM_TARGET command.  It is important that plhershey-unicode.h gets
built before our core library so the rest of this post concerns the
dependency problem with ADD_CUSTOM_TARGET.

> Alan W. Irwin wrote:
>> I am running into a dependency issue with CMake 2.4.3 on Linux.  I find
>> if I run cmake in an initially empty build directory followed by make, then all
>> is well, i.e., everything builds without problems.  But if I change nothing
>> in the source tree and run make again, the result surprised me by taking
>> almost as long to complete as the first make.
> [snip]
>> add_custom_target(
>> plhershey-unicode.h
>
> Read the documentation of add_custom_target.  The first sentence says
>
>  Adds a target with the given name that executes the given commands
>  every time the target is built.
>

"every time the target is built" implies there are some conditions where the
target is not built.  To help clarify that issue here is the full quote of
the documentation.

"Adds a target with the given name that executes the given commands
every time the target is built.  If the ALL option is specified it
indicates that this target should be added to the default build target
so that it will be run every time (the command cannot be called ALL)."

The clear implication of this documentation is that you use ALL when you
want the target to be built every time, and without ALL it will be
conditionally built depending on dependencies.

To keep this e-mail self-contained here is the code fragment in question
again:

**********************
add_executable(plhershey-unicode-gen ${plhershey-unicode-gen_SRCS})

add_custom_target(
plhershey-unicode.h
${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode-gen${EXEEXT}
${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
plhershey-unicode.h
DEPENDS
${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
)
add_dependencies(plhershey-unicode.h plhershey-unicode-gen)

**********************

Note, because of the documentation of ALL I deliberately did not use the ALL
option, and I therefore expected this target would only be built when one of
its dependencies got built first, i.e., from the CMake code fragment below
when either ${plhershey-unicode-gen_SRCS} got changed (which would rebuild
plhershey-unicode-gen) or when
${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv got changed.

Am I misinterpreting the documentation of ALL or is there a dependency bug
for CMake-2.4.3 custom targets when the ALL option is not used?

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 Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list