Skip to content

Instantly share code, notes, and snippets.

@TheBurnDoc
Created October 21, 2013 11:22
Show Gist options
  • Save TheBurnDoc/7082283 to your computer and use it in GitHub Desktop.
Save TheBurnDoc/7082283 to your computer and use it in GitHub Desktop.
This Gist shows how to integrate Doxygen HTML doc generating into your CMake project. It assumes that a file called Doxyfile.cmake exists in the project, from which it generates the final Doxyfile (which means you can embed CMake variables such as directories in Doxyfile.cmake rather than hard-coding them)
# Use -DBUILD_DOCUMENTATION=ON to enable Doxygen at build-time
option (BUILD_DOCUMENTATION
"Use Doxygen to create the HTML based API documentation" OFF)
# Build Doxygen HTML docs
if (BUILD_DOCUMENTATION)
FIND_PACKAGE(Doxygen)
if (NOT DOXYGEN_FOUND)
message (FATAL_ERROR
"Doxygen not found on system, cannot build documentation")
endif ()
configure_file (
${CMAKE_SOURCE_DIR}/Doxyfile.cmake
${CMAKE_SOURCE_DIR}/build/Doxyfile)
add_custom_target (doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/build/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
SOURCES ${CMAKE_SOURCE_DIR}/build/Doxyfile
COMMENT "Generating Doxygen HTML documentation")
endif ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment