[CMake] Custom build command for documentation
Pau Garcia i Quiles
pgquiles at elpauer.org
Tue Jan 8 05:01:53 EST 2008
Quoting Alexander.Camek at elektrobit.com:
> Hi all,
>
> currently I can generate for some subdirectories my Latex and
> Doxygen documentation. This is done like it is described in the
> cmake FAQ.
> What I now want to do is to collect all this commands of the
> subdirectory and put it in an unique common build command, e.g. make
> doc.
> The idea is that the user can generate all documents with one common
> command, like cmake currently does during source build when a user
> types make all.
>
> The problem is that when I add a custom target it doesn't know about
> targets given by a ADD_SUBDIRECTORY command.
>
> Consider following structure:
>
> \src
> \modules
> \module1 -> some docu
> \module2 -> some docu
> \module3 -> some docu
> \tools
> \tool1 -> some docu
> \tool2 -> some docu
>
> Then think about the user who types in "make doc" and all documents
> of the whole build is generated.
>
> Is it with current release (cmake 2.4.7) possible to generate such a
> command for generating documentation?
>
> If not so. Does the next big step of cmake (cmake 2.5 or 2.6 ???)
> consider something like a doc command in it? Similar to the install
> command which collects all informations of the to installable files.
>
> Thanks for your help.
>
> Greetings
>
> Alexander
I'm using this:
# Create a "make doc" target using Doxygen
# Prototype:
# GENERATE_DOCUMENTATION(doxygen_config_file)
# Parameters:
# doxygen_config_file Doxygen configuration file (must be in the
root of the source directory)
MACRO(GENERATE_DOCUMENTATION DOXYGEN_CONFIG_FILE)
FIND_PACKAGE(Doxygen)
SET(DOXYFILE_FOUND false)
IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
SET(DOXYFILE_FOUND true)
ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
IF( DOXYGEN_FOUND )
IF( DOXYFILE_FOUND )
# Add target
ADD_CUSTOM_TARGET( doc ALL ${DOXYGEN_EXECUTABLE}
"${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" )
# Add .tag file and generated documentation to the list of
files we must erase when distcleaning
# Read doxygen configuration file
FILE( READ ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}
DOXYFILE_CONTENTS )
STRING( REGEX REPLACE "\n" ";" DOXYFILE_LINES ${DOXYFILE_CONTENTS} )
# Parse .tag filename and add to list of files to delete if it exists
FOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )
STRING( REGEX REPLACE ".*GENERATE_TAGFILE *= *([^
^\n]+).*" "\\1" DOXYGEN_TAG_FILE ${DOXYLINE} )
ENDFOREACH( DOXYLINE )
ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_TAG_FILE} )
# Parse doxygen output doc dir and add to list of files to
delete if it exists
FOREACH( DOXYLINE ${DOXYFILE_CONTENTS} )
STRING( REGEX REPLACE ".*OUTPUT_DIRECTORY *= *([^
^\n]+).*" "\\1" DOXYGEN_DOC_DIR ${DOXYLINE} )
ENDFOREACH( DOXYLINE )
ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_DOC_DIR} )
ADD_TO_DISTCLEAN( ${PROJECT_BINARY_DIR}/${DOXYGEN_DOC_DIR}.dir )
ELSE( DOXYFILE_FOUND )
MESSAGE( STATUS "Doxygen configuration file not found -
Documentation will not be generated" )
ENDIF( DOXYFILE_FOUND )
ELSE(DOXYGEN_FOUND)
MESSAGE(STATUS "Doxygen not found - Documentation will not be generated")
ENDIF(DOXYGEN_FOUND)
ENDMACRO(GENERATE_DOCUMENTATION)
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
More information about the CMake
mailing list