[CMake] What is the preferred method of establishing the dependence of a custom command on an executable target?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Apr 8 18:03:00 EDT 2007


On 2007-04-08 11:06-0700 Brandon J. Van Every wrote:

> CMake (unfortuantely) distinguishes between target level dependencies and 
> file level dependencies.  An ADD_CUSTOM_COMMAND only creates file level 
> dependencies, and these fail in various circumstances.  To create target 
> level dependencies, you create an ADD_CUSTOM_TARGET that depends on the file 
> output of your ADD_CUSTOM_COMMAND.  You should connect all your important 
> dependencies at the target level.

I have partially followed that rule in this chain of dependencies.  My
library depends on a custom target which file depends on the custom command
which file depends on the executable.  (My example showed just those last
two.) To illustrate the dependency chain we currently have the following
arrangement:

           t             f              f 
library =====> target =====> command =====> executable

where the "t" and "f" above the arrows refer to whether those arrows represent
a target dependency or file dependency.

It appears you think I will get more reliable cross-platform results if I
make the custom target depend directly on the executable and file depend (as
now) on the custom command, and remove the file dependency of the custom
command on the executable.  That is you are suggesting I turn the above
diagram into the following:

           t             f
library =====> target =====> command
                      \
                       \ t
 		        ===> executable

This new arrangement bypasses the whole issue of having a custom command
file depend on an executable so it sounds like it might have a much better
chance of working cross-platform to me. However, which dependency of the
custom target has precedence, the file depends on the custom command or the
target depends on the executable?  The executable has to be created first
since the custom command uses it so this new scenario will only work if the
target depends always takes precedence (i.e., it must be satisfied first)
before the file depends.

IMPORTANT question for the CMake developers: If this new dependency scenario
works now for CMake, can I always rely on target dependencies always taking
precedence over file dependencies from here on out?

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