[CMake] appending srcs to custom_target, or doxygen support

Hendrik Sattler post at hendrik-sattler.de
Thu Jul 2 08:41:08 EDT 2009


Zitat von Marcel Loose <loose at astron.nl>:

> On Thursday 02 July 2009 07:27:49 Hendrik Sattler wrote:
>> Am Mittwoch 01 Juli 2009 18:03:10 schrieb Mark Lohry:
>> > Apologies if this has been covered, but I'm only seeing occasional
>> > references to doxygen in the archives.
>> >
>> > Is there any built-in mechanism for some kind of "make doc" to invoke
>> > building documentation through doxygen, or does it require
>> > ADD_CUSTOM_TARGET?
>> >
>> > Presuming there isn't, I have several library directories beneath the top
>> > source directory, each of which contains it's own doxygen config file.
>> > I'd like the flexibility of building within just those libraries
>> > individually (i.e. run cmake on ./src/lib1/, and make doc to use
>> > ./src/lib1/DOXYGEN_CONFIG_FILE), or building all at once with the top
>> > level cmakelists (i.e. run cmake on ./src, and make doc to build all the
>> > individual library docs.)
>> >
>> > in ./src/lib1/cmakelists.txt I have:
>> >
>> > if(DOXYGEN_EXECUTABLE AND UNIX)
>> >   IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
>> >     message( "***** Doxygen config file found *****" )
>> >     SET(DOXYFILE_FOUND true)
>> >     ADD_CUSTOM_TARGET( doc ${DOXYGEN_EXECUTABLE}
>> >       "${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE}" )
>> >     install(DIRECTORY ${CMAKE_SOURCE_DIR}/doc/ DESTINATION
>> > ${docdir}/html) ENDIF(EXISTS
>> > ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
>> > endif(DOXYGEN_EXECUTABLE AND UNIX)
>>
>> That ADD_CUSTOM_TARGET should be a ADD_CUSTOM_COMMAND (so only rebuilt when
>> needed). Simple create the
>>   ADD_CUSTOM_TARGET(doc)
>> globally and another custom target for each doxygen documentation:
>>   ADD_CUSTOM_TARGET(subproject1-doc)
>> and add dependencies on your specific doc target to the global doc target.
>> You can also add a dependency on the target that this documentation is for,
>> so it automatically gets build if you do not build all of the project.
>>
>> That usually works fine here.
>>
> The only downside to this solution is that you can only issue a 'make doc' in
> the top-level build directory, not further down in the tree. I've stumbled
> upon the same issue when creating a 'check' target in order to compile, link
> and run a series of test programs (like the GNU Autotools do).

But you can issue 'make subproject1-doc'. The result is also a finer  
dependency tree. For OpenOBEX, I do it exactly like this and 'make  
doc' uses doxygen for the library documentation and uses docbook XML  
files for application manual pages. All is build by "make all" but  
also by "make doc". The manuals are automatically built when building  
the applications, same for the library, without using the global doc  
target.

HS




More information about the CMake mailing list