[CMake] custom doxygen target

Stephan Menzel smenzel at gmx-gmbh.de
Wed Jul 25 06:22:51 EDT 2007


Hello,

I'd like to create a custom doxygen target for a project. The relevant parts 
look like that:

 /
  doc/Doxyfile.in
  lib/[files with all the documentation]
  build/
  CMakeLists.txt

Now what I'd like to have is a doxygen target where I can do something like 
this:

 $ cd build
 $ cmake ../
 $ make api-docs

I found some clues on this list and got this far:

        INCLUDE( ${CMAKE_ROOT}/Modules/FindDoxygen.cmake)
        CONFIGURE_FILE(${MYPROJECT_SOURCE_DIR}/doc/Doxyfile.in
                ${MYPROJECT_BINARY_DIR}/api-docs/Doxyfile
                        @ONLY IMMEDIATE)
        ADD_CUSTOM_TARGET(api-docs ALL ${DOXYGEN}
                \"${MYPROJECT_BINARY_DIR}/api-docs/Doxyfile\" )

I included this into ./CMakeLists.txt and it works well: The only problem is: 
it is always executed when I do make. "make api-docs" does not work, so I 
tried it that way:

ADD_CUSTOM_COMMAND(OUTPUT api-docs COMMAND doxygen)
IF (COMMAND doxygen)
        INCLUDE( ${CMAKE_ROOT}/Modules/FindDoxygen.cmake)
        CONFIGURE_FILE(${MYPROJECT_SOURCE_DIR}/doc/Doxyfile.in
                ${MYPROJECT_BINARY_DIR}/api-docs/Doxyfile
                        @ONLY IMMEDIATE)
        ADD_CUSTOM_TARGET(api-docs ALL ${DOXYGEN}
                \"${MYPROJECT_BINARY_DIR}/api-docs/Doxyfile\" )
ENDIF (COMMAND doxygen)

However, this doesn't work either. So the basic question is: How can I specify 
a target for "make <target>" and do something in the CMakeLists.txt only when 
that target is given? I don't want doxygen to run every time. Only when I say 
so.

I suppose I fail to understand the "command" and "target" mechanism. What 
would be an appropriate way to do this.

Thanks and Greetings...

Stephan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://public.kitware.com/pipermail/cmake/attachments/20070725/a02c4a2f/attachment.pgp


More information about the CMake mailing list