I found on the Web a sample cmake file and put it in the /doc
subdirectory of my project, where the file myproject.doxgen
is also located, containi
The way the CMake file you've shown is set up, it creates a target called doc
; building that target (such as running make doc
) generates the doxymentation. The target is not part of make all
(or equivalent); to make it such, add ALL
into the custom target creation:
add_custom_target(
doc ALL
COMMAND #... everything else as before
)
If you want to limit this target to only build in a particular configuration (as you've mentioned in comments), you can use generator expressions:
add_custom_target(
doc ALL
COMMAND $<$<CONFIG:Release>:${DOXYGEN_EXECUTABLE} ${doxyfile_in}>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
It might happen that some CMake generators do not cope well with an empty COMMAND
. With this in mind, the following should be fail-safe:
add_custom_target(
doc ALL
COMMAND
$<$<CONFIG:Release>:${DOXYGEN_EXECUTABLE} ${doxyfile_in}>
$<$<NOT:$<CONFIG:Release>>:${CMAKE_COMMAND} -E echo "Only done in Release builds">
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)