1#-------------------------------------------------------------------------------
2# SPDX-License-Identifier: BSD-3-Clause
3# SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4#
5#
6#-------------------------------------------------------------------------------
7
8add_custom_target(docs)
9
10find_package(Python3)
11find_package(Sphinx)
12find_package(PythonModules COMPONENTS sphinx-rtd-theme sphinxcontrib.plantuml)
13find_package(Git)
14
15set(SPHINXCFG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/user_guide)
16
17if (SPHINX_FOUND AND PY_SPHINX-RTD-THEME_FOUND AND PY_SPHINXCONTRIB.PLANTUML AND GIT_FOUND)
18
19    file(GLOB_RECURSE SPHINXCFG_DOC_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.rst conf.py)
20
21    add_custom_command(OUTPUT "${SPHINXCFG_OUTPUT_PATH}/html/index.html"
22        OUTPUT "${SPHINXCFG_OUTPUT_PATH}/html/"
23        COMMAND "${SPHINX_EXECUTABLE}" -W -b html "${CMAKE_CURRENT_SOURCE_DIR}" "${SPHINXCFG_OUTPUT_PATH}/html"
24        WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/docs"
25        DEPENDS ${SPHINXCFG_DOC_FILES}
26    )
27    add_custom_target(rmm_docs_userguide_html
28        DEPENDS "${SPHINXCFG_OUTPUT_PATH}/html/index.html"
29        DEPENDS "${SPHINXCFG_OUTPUT_PATH}/html/"
30    )
31    add_dependencies(docs rmm_docs_userguide_html)
32endif()
33