[Cmake] Re: ADD_CUSTOM_COMMAND etc

Andy Cedilnik andy.cedilnik at kitware.com
Wed Apr 9 09:54:28 EDT 2003


Hi Nils,

Custom command has to be attached to a target. Targets are executables,
libraries or custom targets. So, you always use some target, but if you
want dependency checking for custom rules, you need to add custom
commands.

			Andy

On Wed, 2003-04-09 at 09:40, Nils H. Busch wrote:
> OK, I see.
> But should one issue both or is one sufficient ? From what you said, I would gather that in the
> latter case ADD_CUSTOM_COMMAND is better, as it does dependency checking, although I don't know
> exactly what the DEPENDS dependencies should be in my case of building a doxygen target. Maybe
> the doxygen.config file and/or the commented source code files (isn't this handled by doxygen
> itself ?) ?
> What remains unclear to me, is, however, how ADD_CUSTOM_TARGET uses the command added by
> ADD_CUSTOM_COMMAND, if actually both are needed ?
> 
> I also noticed that specifying ALL with ADD_CUSTOM_TARGET builds the doc target when issuing a
> make command, whereas without it I had to cd to the directory where the Makefile for the doc
> target was.
> I tried to get some information on how to build a doc target from the ITK sources as well, but
> failed to see, how it is done there.
> 
> Maybe you can provide me with a way how to do this correctly.
> 
> Here is what I do for now:
> 
> In the top level CMakeLists.txt:
> 
> INCLUDE (${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
> IF (BUILD_DOCUMENTATION)
>   SUBDIRS(utilities/Doxygen)
> ENDIF (BUILD_DOCUMENTATION)
> 
> In the utilities/Doxygen/CMakeLists.txt:
> 
> IF (BUILD_DOCUMENTATION)
> 
>   #
>   # Configure the doxygen configfile, then add target
>   #
>   CONFIGURE_FILE(
>     ${FOO_SOURCE_DIR}/utilities/Doxygen/doxygen.config.in
>     ${FOO_BINARY_DIR}/utilities/Doxygen/doxygen.config)
> 
>   ADD_CUSTOM_TARGET(doc
>    ALL
>    ${DOXYGEN}
>    ${FOO_BINARY_DIR}/utilities/Doxygen/doxygen.config)
> 
> ENDIF (BUILD_DOCUMENTATION)
> 
> Thanks.
> 
> --
>     Nils H. Busch
>     Max-Planck-Institute of Cognitive Neuroscience
>     phone:  ++49 (341) 9940-035 fax:  ++49 (341) 9940-204
>     e-mail: nilsb at cns.mpg.de
> 
> 




More information about the CMake mailing list