1#------------------------------------------------------------------------------- 2# Copyright (c) 2020-2021, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8cmake_minimum_required(VERSION 3.15) 9 10add_custom_target(docs) 11 12list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) 13 14find_package(Sphinx) 15find_package(Doxygen 1.8.0) 16find_package(LATEX COMPONENTS PDFLATEX) 17 18################################## ENV ######################################### 19 20project("Trusted Firmware M. Documentation" LANGUAGES) 21 22set(SPHINXCFG_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) 23set(SPHINXCFG_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}) 24set(SPHINXCFG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/user_guide) 25 26set(DOXYCFG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/reference_manual) 27set(DOXYCFG_DOXYGEN_CFG_DIR ${CMAKE_SOURCE_DIR}/doxygen) 28 29# Enable to request the interface to build the doxygen documentation as well 30set(DOXYCFG_DOXYGEN_BUILD False) 31 32################################## SPHINX ###################################### 33 34file(GLOB_RECURSE SPHINXCFG_DOC_FILES ${SPHINXCFG_SOURCE_PATH}/*.rst ${SPHINXCFG_SOURCE_PATH}/*.md) 35 36add_custom_target(tfm_docs_userguide_html ALL 37 COMMAND "${SPHINX_EXECUTABLE}" -W -b html -j 8 -c ${SPHINXCFG_CONFIG_PATH} ${SPHINXCFG_SOURCE_PATH} "${SPHINXCFG_OUTPUT_PATH}/html" 38 WORKING_DIRECTORY ${SPHINXCFG_SOURCE_PATH} 39 DEPENDS ${SPHINXCFG_DOC_FILES} 40) 41add_dependencies(docs tfm_docs_userguide_html) 42 43add_custom_target(tfm_docs_userguide_pdf ALL 44 COMMAND "${SPHINX_EXECUTABLE}" -W -b latex -j 8 -c ${SPHINXCFG_CONFIG_PATH} ${SPHINXCFG_SOURCE_PATH} "${SPHINXCFG_OUTPUT_PATH}/latex" 45 COMMAND ${PDFLATEX_COMPILER} -output-directory "${SPHINXCFG_OUTPUT_PATH}/latex" TF-M.tex 46 COMMAND ${CMAKE_COMMAND} -E copy "${SPHINXCFG_OUTPUT_PATH}/latex/TF-M.pdf" "${SPHINXCFG_OUTPUT_PATH}/tf-m_user_guide.pdf" 47 WORKING_DIRECTORY ${SPHINXCFG_SOURCE_PATH} 48 DEPENDS ${SPHINXCFG_DOC_FILES} 49) 50add_dependencies(docs tfm_docs_userguide_pdf) 51 52################################## DOXYGEN ##################################### 53 54configure_file(${CMAKE_SOURCE_DIR}/doxygen/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) 55file(GLOB_RECURSE DOXYCFG_DOC_FILES ${CMAKE_SOURCE_DIR}/*.c ${CMAKE_SOURCE_DIR}/*.h) 56 57add_custom_command(OUTPUT ${DOXYCFG_OUTPUT_PATH}/html 58 OUTPUT ${DOXYCFG_OUTPUT_PATH}/latex 59 OUTPUT ${DOXYCFG_OUTPUT_PATH}/latex/refman.pdf 60 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 61 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 62 DEPENDS ${DOXYCFG_DOC_FILES} 63) 64add_custom_target(tfm_docs_refman_html ALL 65 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 66 DEPENDS ${DOXYCFG_OUTPUT_PATH}/html 67) 68add_dependencies(docs tfm_docs_refman_html) 69 70add_custom_command(OUTPUT "${DOXYCFG_OUTPUT_PATH}/latex/refman.pdf" 71 COMMAND "${PDFLATEX_COMPILER} refman.tex" 72 COMMAND ${CMAKE_COMMAND} -E copy refman.tex ${DOXYCFG_OUTPUT_PATH}/tf-m_reference_manual.pdf 73 WORKING_DIRECTORY ${DOXYCFG_OUTPUT_PATH}/latex/ 74 DEPENDS "${DOXYCFG_OUTPUT_PATH}/latex/refman.tex" 75) 76add_custom_target(tfm_docs_refman_pdf 77 DEPENDS ${DOXYCFG_OUTPUT_PATH}/latex/refman.pdf 78 DEPENDS tfm_docs_refman_html 79) 80add_dependencies(docs tfm_docs_refman_pdf) 81 82