[Cmake] Make clean

Brad King brad . king at kitware . com
Mon, 1 Dec 2003 15:33:22 -0500 (EST)


On Thu, 27 Nov 2003, Gerhard Esterhuizen wrote:

> A few comments and questions:
>
> 1. Although I understand the motivation for out-of-source builds, all
> programs (e.g. Doxygen) doesn't support it that well (in that it assumes
> the presence of certain file in its CWD and therefore doesn't benefit
> from the use of variables such as CMAKE_CURRENT_SOURCE).

We use doxygen with out of source builds all the time.  The key is to
configure the doxygen input file with cmake to have the right paths:

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/api-docs.doxy.in
               ${CMAKE_CURRENT_BINARY_DIR}/api-docs.doxy @ONLY IMMEDIATE)

Then in the .in file use @CMAKE_CURRENT_SOURCE_DIR@ to refer to the source
tree, and setup the custom command to use the configured version of the
.doxy file from the build tree.

> 2. IF I refer to CMAKE_CURRENT_SOURCE in the MAIN_DEPENDENCY part of an
> ADD_CUSTOM_COMMAND, i.e.
>
> ADD_CUSTOM_COMMAND(OUTPUT api-docs-cmd
> 	           COMMAND doxygen
> 		   ARGS $(CMAKE_CURRENT_SOURCE)/api-docs.doxy
> 		   MAIN_DEPENDENCY $(CMAKE_CURRENT_SOURCE)/api-docs.doxy)
>
> CMake errors with "CMake Error: CMake failed to properly look up
> cmSourceFile: $(CMAKE_CURRENT_SOURCE)/api-docs.doxy". However,
> specifying it as part of DEPENDENCIES works fine:
>
> ADD_CUSTOM_COMMAND(... bla ...
> 		   DEPENDENCIES $(CMAKE_CURRENT_SOURCE)/api-docs.doxy)
>
> I could not find anything in the docs (help or PDF) that explains this.

This may be a bug.  Please submit this issue to the bug tracker at
http://www . cmake . org/Bug .   Thanks.

> 3. Why should I use ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET when the
> following line suffices ?
>
> ADD_CUSTOM_TARGET(api-docs ALL doxygen
> $(CMAKE_CURRENT_SOURCE)/api-docs.doxy DEPENDS
> $(CMAKE_CURRENT_SOURCE)/api-docs.doxy)

If this does what you want, then it is enough.  The combination of the two
commands can be used to create much more complicated rules that chain
together several dependencies.

> 4. Where do I find a list of variables that CMake uses (e.g.
> CMAKE_CURRENT_SOURCE) ?

The "Mastering CMake" book covers this in Appendix A.  We have plans to
have the list generated as part of the CMake man page, but this has not
yet been implemented.

-Brad