[CMake] How to INSTALL generated files

Alan W. Irwin irwin at beluga.phys.uvic.ca
Sun Dec 3 19:10:12 EST 2006


Hi Eric:

It appears that at least part of your problem is that you are using the
add_custom_target command and to quote the documentation:

"The target has no output file and is ALWAYS CONSIDERED OUT OF DATE"

Thus, whenever a custom target is referred to the commands in it are always
executed whether they need it or not.  This is bad if the command is
time-consuming at all.  So the rule of thumb I always use is never put
anything serious (that is time-consuming) in the COMMAND of a custom target.

To illustrate the point here is what I would suggest to replace the custom
target you gave us:

ADD_CUSTOM_COMMAND(
    OUTPUT ${DOXYGEN_OUTPUT}
    COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_INPUT}
    COMMAND ${CMAKE_COMMAND} -E echo "Done."
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    DEPENDS ${DOXYGEN_INPUT}
    )

ADD_CUSTOM_TARGET(apidoc ALL DEPENDS ${DOXYGEN_OUTPUT})

where ${DOXYGEN_OUTPUT} is one of the list of files created by doxygen.

Note the distinction between custom target and custom command.  With this
style, apidoc is executed whenever the pseudo-target all is executed (i.e.,
if you simply type "make" on the command line), but since there is no
COMMAND associated with the apidoc target nothing happens for that target
except the dependency check on ${DOXYGEN_OUTPUT}.  However, that check means
in turn that ${DOXYGEN_EXECUTABLE} is only executed if ${DOXYGEN_OUTPUT} is
out of date, i.e., does not exist or has an earlier date than
${DOXYGEN_INPUT}.

I hope this suggested style helps solve your problem.

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