Select Git revision
CMakeLists.txt
CWG-10 Skeleton C++.
Klaas Kliffen authored and
Mark de Wever
committed
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CMakeLists.txt 2.13 KiB
# Copyright (C) ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0
find_package(Doxygen REQUIRED)
find_package(Sphinx REQUIRED)
#
# The code is based on
# https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/
#
#
# Determine the public headers for the API documentation.
#
get_target_property(HELLO_PUBLIC_HEADER_DIR hello INTERFACE_INCLUDE_DIRECTORIES)
file(GLOB_RECURSE HELLO_PUBLIC_HEADERS ${HELLO_PUBLIC_HEADER_DIR}/*)
#
# Configure Doxygen.
#
set(DOXYGEN_PROJECT_NAME ${CMAKE_PROJECT_NAME})
set(DOXYGEN_INPUT ${HELLO_PUBLIC_HEADER_DIR})
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIRECTORY}/html/index.html)
set(DOXYFILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in")
set(DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
configure_file(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
#
# Adds Doxygen target.
#
add_custom_command(
OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${HELLO_PUBLIC_HEADERS}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE}
${DOXYFILE_IN}
COMMENT "Generating documentation with Doxygen")
add_custom_target(doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
set(SPHINX_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/sphinx")
set(SPHINX_BUILD "${CMAKE_CURRENT_BINARY_DIR}/sphinx")
set(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)
# Only regenerate Sphinx when: - Doxygen has rerun - Our doc files have been
# updated - The Sphinx config has been updated
add_custom_command(
OUTPUT ${SPHINX_INDEX_FILE}
COMMAND
${SPHINX_EXECUTABLE} -b html
# Tell Breathe where to find the Doxygen output
-Dbreathe_projects.CPP=${DOXYGEN_OUTPUT_DIRECTORY}/xml ${SPHINX_SOURCE}
${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS # Other docs files you want to track should go here (or in some
# variable)
${SPHINX_SOURCE}/index.rst ${DOXYGEN_INDEX_FILE}
MAIN_DEPENDENCY ${SPHINX_SOURCE}/conf.py
COMMENT "Generating documentation with Sphinx")
# Nice named target so we can run the job easily
add_custom_target(sphinx ALL DEPENDS ${SPHINX_INDEX_FILE})