[CMake] question on file dependencies

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat May 5 10:05:15 EDT 2007


On 2007-05-05 09:41-0300 Bráulio Oliveira wrote:

> Hello all,
>
> I'm having some problems on write code to handle .ts due to file
> dependencies. So, I've made a small example of what I need to work. Here It
> comes:
>
> The three text files: a, b and c, all int the source directory. I write the
> following code:
>
> ADD_CUSTOM_COMMAND(OUTPUT a
>                  COMMAND cat a
>                 )
> ADD_CUSTOM_COMMAND(OUTPUT b
>                  COMMAND cat b
>                 )
> SET_SOURCE_FILES_PROPERTIES(b
>                           PROPERTIES
>                           OBJECT_DEPENDS a
>                          )
> SET_SOURCE_FILES_PROPERTIES(c
>                           PROPERTIES
>                           OBJECT_DEPENDS b
>                          )
> ADD_CUSTOM_COMMAND(OUTPUT c
>                  COMMAND cat c
>                 )
>
> The I add an executable that depends on c. What I want is that the three
> cat's are executed, because c depends on b and b on a. But this doesn't
> work.
> Any suggestions?

See the documentation (at http://cmake.org/HTML/Documentation.html) under
ADD_DEPENDENCIES which tersely summarizes the way that dependencies should
be established between various kinds of CMake entities.  For the above case
OBJECT_DEPENDS should not be used, and instead you should use the DEPENDS
property of ADD_CUSTOM_COMMAND to create dependencies between various
ADD_CUSTOM_COMMAND's.  Furthermore, to establish the dependencies of your
executable you can simply put generated source files or headers into the
list of sources for the executable (currently only working if the file
generation occurs in the same directory) or for different directories use
ADD_DEPENDENCIES to make your executable depend on an empty custom target
which in turn depends on your last ADD_CUSTOM_COMMAND.

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
__________________________


More information about the CMake mailing list