[CMake] Help with custom targets

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sat Mar 3 11:11:27 EST 2007


On 2007-03-03 16:10+0100 Ulrik Mikaelsson wrote:

> My problem right now is that I would like to define my edje-resources
> as special targets, and have them depend on their respective
> source-files, but I haven't managed to make them behave as I want.
>
> I've come pretty close using the ADD_CUSTOM_COMMAND() in OUTPUT mode,
> but for some reason I have not been able to make the dependencies work
> such that when I update the source-files, and run make, the compiled
> resources are updated.

My experience is custom command dependencies generally work if you specify
full pathnames and you always have a custom target file-depending on the
OUTPUT of a custom command.

Here is one CMake fragment illustrating a working example:

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

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode-gen${EXEEXT}
${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
plhershey-unicode.h
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode-gen${EXEEXT}
${CMAKE_SOURCE_DIR}/fonts/plhershey-unicode.csv
)

add_custom_target(
plhershey-unicode.h_built
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/plhershey-unicode.h

This dependency chain was complicated by the fact that my custom command
file-depended on the results of add_executable, and my custom target was
target-depended by an add_library in another directory.  But this dependency
chain works as expected with plhershey-unicode.h being generated only when
needed (which is important because an earlier incorrect version of this
generated the header every time which lead to an expensive library rebuild
every time).

If this pattern of working dependencies does not give you any helpful ideas,
could you give a simple example of the dependency problem you are
encountering?

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