2022-02-15 21:33:11 +00:00
|
|
|
# Serene Programming Language
|
|
|
|
#
|
|
|
|
# Copyright (c) 2019-2022 Sameer Rahmani <lxsameer@gnu.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 2.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2022-02-12 22:25:22 +00:00
|
|
|
|
|
|
|
find_package(Doxygen REQUIRED)
|
2022-02-15 21:33:11 +00:00
|
|
|
find_package(Sphinx REQUIRED)
|
2022-02-12 22:25:22 +00:00
|
|
|
|
|
|
|
# Find all the public headers
|
2022-02-15 21:33:11 +00:00
|
|
|
get_target_property(SERENE_PUBLIC_HEADER_DIR serene INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
|
|
|
|
# doxygen_add_docs(docs
|
|
|
|
# #"${CMAKE_CURRENT_SOURCE_DIR}/index.md"
|
|
|
|
# "${PROJECT_SOURCE_DIR}/src/"
|
|
|
|
# ${INCLUDE_DIR})
|
2022-02-12 22:25:22 +00:00
|
|
|
|
2022-02-15 21:33:11 +00:00
|
|
|
#file(GLOB_RECURSE SERENE_PUBLIC_HEADER_DIR ${SERENE_PUBLIC_HEADER_DIR}/*.h)
|
|
|
|
file(GLOB_RECURSE SERENE_PUBLIC_HEADERS ${INCLUDE_DIR}/*.h)
|
|
|
|
message(STATUS ".........")
|
|
|
|
message(STATUS "${SERENE_PUBLIC_HEADERS}")
|
2022-02-12 22:25:22 +00:00
|
|
|
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/)
|
2022-02-15 21:33:11 +00:00
|
|
|
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
|
2022-02-12 22:25:22 +00:00
|
|
|
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html)
|
|
|
|
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
|
|
|
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
|
|
|
|
|
|
|
# Replace variables inside @@ with the current values
|
|
|
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
2022-02-15 21:33:11 +00:00
|
|
|
|
2022-02-12 22:25:22 +00:00
|
|
|
# Doxygen won't create this for us
|
|
|
|
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
|
2022-02-15 21:33:11 +00:00
|
|
|
DEPENDS ${SERENE_PUBLIC_HEADERS}
|
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
|
|
|
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
|
|
|
COMMENT "Generating docs"
|
|
|
|
VERBATIM)
|
2022-02-12 22:25:22 +00:00
|
|
|
|
2022-02-15 21:33:11 +00:00
|
|
|
# Nice named target so we can run the job easily
|
2022-02-12 22:25:22 +00:00
|
|
|
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
|
|
|
|
|
|
|
|
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
|
2022-02-15 21:33:11 +00:00
|
|
|
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.Serene=${DOXYGEN_OUTPUT_DIR}/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)
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/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})
|
|
|
|
|
|
|
|
# Add an install target to install the docs
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
install(DIRECTORY ${SPHINX_BUILD}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
|
|
|
|
|
|
|
add_dependencies(serene Doxygen Sphinx)
|