mirror of https://github.com/CGAL/cgal
279 lines
12 KiB
CMake
279 lines
12 KiB
CMake
project(Documentation NONE)
|
|
|
|
option(BUILD_DOC "Build the doxygen documentation" OFF)
|
|
if(NOT BUILD_DOC)
|
|
return()
|
|
endif()
|
|
|
|
# Visual Studio users might appreciate this
|
|
# set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
macro(subdirlist result curdir)
|
|
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
|
set(dirlist "")
|
|
foreach(child ${children})
|
|
if(IS_DIRECTORY ${curdir}/${child})
|
|
set(dirlist ${dirlist} ${child})
|
|
endif()
|
|
endforeach()
|
|
set(${result} ${dirlist})
|
|
endmacro()
|
|
|
|
function(configure_doxygen_package CGAL_PACKAGE_NAME)
|
|
if(CGAL_BRANCH_BUILD)
|
|
set(CGAL_PACKAGE_DOC_DIR ${CMAKE_SOURCE_DIR}/${CGAL_PACKAGE_NAME}/doc/${CGAL_PACKAGE_NAME})
|
|
else()
|
|
set(CGAL_PACKAGE_DOC_DIR ${CMAKE_SOURCE_DIR}/doc/${CGAL_PACKAGE_NAME})
|
|
endif()
|
|
if(NOT IS_DIRECTORY ${CGAL_PACKAGE_DOC_DIR})
|
|
message(STATUS "${CGAL_PACKAGE_NAME} reported but has no doc dir: ${CGAL_PACKAGE_DOC_DIR}")
|
|
return()
|
|
else()
|
|
message(STATUS "Configuring documentation of ${CGAL_PACKAGE_NAME}")
|
|
endif()
|
|
|
|
set(CGAL_PACKAGE_DIR ${CMAKE_SOURCE_DIR}/${CGAL_PACKAGE_NAME})
|
|
if(EXISTS ${CGAL_PACKAGE_DOC_DIR}/Doxyfile.in)
|
|
set(CGAL_DOC_PACKAGE_DEFAULTS ${CGAL_DOC_DXY_DIR}/${CGAL_PACKAGE_NAME}_defaults.dxy)
|
|
file(REMOVE ${CGAL_DOC_PACKAGE_DEFAULTS})
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "@INCLUDE = ${CGAL_DOC_DOXY_DEFAULT}\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "OUTPUT_DIRECTORY = ${CGAL_DOC_OUTPUT_DIR}/${CGAL_PACKAGE_NAME}\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "HTML_OUTPUT = .\n")
|
|
|
|
if(CGAL_DOC_CREATE_LOGS)
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "WARN_LOGFILE = ${CGAL_DOC_LOG_DIR}/${CGAL_PACKAGE_NAME}.log\n")
|
|
endif()
|
|
|
|
if (CGAL_DOC_RELEASE)
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "GENERATE_TODOLIST = NO\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "GENERATE_BUGLIST = NO\n")
|
|
endif()
|
|
|
|
if(EXISTS "${CGAL_PACKAGE_DIR}/examples")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "EXAMPLE_PATH = ${CGAL_PACKAGE_DIR}/examples\n")
|
|
endif()
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "GENERATE_TAGFILE = ${CGAL_DOC_TAG_GEN_DIR}/${CGAL_PACKAGE_NAME}.tag\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "STRIP_FROM_PATH = ${CGAL_PACKAGE_DOC_DIR}/\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "STRIP_FROM_PATH += ${CGAL_PACKAGE_DIR}/include/\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "STRIP_FROM_INC_PATH = ${CGAL_PACKAGE_DOC_DIR}/\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "STRIP_FROM_INC_PATH += ${CGAL_PACKAGE_DIR}/include/\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "ALIASES += \"cgalPkgDescriptionBegin{2}=\\details \"\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "ALIASES += \"cgalPkgManuals{2}=<BR>\"\n")
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "INPUT = ${CGAL_PACKAGE_DOC_DIR}\n")
|
|
|
|
# IMAGE_PATH is set by default. For Documentation, we generate the extra path using packages.txt
|
|
set(IMAGE_PATH_VALUES "IMAGE_PATH = ${CGAL_PACKAGE_DOC_DIR}/fig")
|
|
set(DEPENDENCIES "")
|
|
# figure out the dependencies, using the file `dependencies` or `packages.txt` for Documentation
|
|
if (${CGAL_PACKAGE_NAME} STREQUAL "Documentation")
|
|
set(PackageFile ${CGAL_PACKAGE_DOC_DIR}/packages.txt)
|
|
file(READ ${PackageFile} Entries)
|
|
string(REPLACE "\n" ";" EntriesAsList ${Entries})
|
|
foreach(Line ${EntriesAsList})
|
|
if("${Line}" MATCHES "^\\\\package_listing{.+}$")
|
|
string(REGEX REPLACE "^\\\\package_listing{(.+)}$" "\\1" PKG "${Line}")
|
|
list(APPEND DEPENDENCIES ${PKG})
|
|
# update IMAGE_PATH
|
|
SET(IMG_DIR "${CMAKE_SOURCE_DIR}/${PKG}/doc/${PKG}/fig")
|
|
if(EXISTS ${IMG_DIR})
|
|
set(IMAGE_PATH_VALUES "${IMAGE_PATH_VALUES} \\\n ${IMG_DIR}")
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
set(IMAGE_PATH_VALUES ${IMAGE_PATH_VALUES} PARENT_SCOPE)
|
|
set(DOCUMENTATION_DEPENDENCIES ${DEPENDENCIES} PARENT_SCOPE)
|
|
else()
|
|
if(EXISTS ${CGAL_PACKAGE_DOC_DIR}/dependencies)
|
|
file(STRINGS ${CGAL_PACKAGE_DOC_DIR}/dependencies DEPENDENCIES)
|
|
endif()
|
|
endif()
|
|
|
|
foreach(depend ${DEPENDENCIES})
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS}
|
|
"TAGFILES += ${CGAL_DOC_TAG_DIR}/${depend}.tag=../${depend}\n")
|
|
endforeach()
|
|
|
|
#now write IMAGE_PATH
|
|
file(APPEND ${CGAL_DOC_PACKAGE_DEFAULTS} "${IMAGE_PATH_VALUES}\n")
|
|
|
|
configure_file(${CGAL_PACKAGE_DOC_DIR}/Doxyfile.in ${CGAL_DOC_DXY_DIR}/${CGAL_PACKAGE_NAME}.dxy)
|
|
|
|
# TODO we also want to run html_post_process per package as a custom_command with POST_BUILD
|
|
# target that build the doc and put the tag file in the generation directory CGAL_DOC_TAG_GEN_DIR
|
|
add_custom_target(${CGAL_PACKAGE_NAME}_internal_doxygen_run
|
|
${DOXYGEN_EXECUTABLE} ${CGAL_DOC_DXY_DIR}/${CGAL_PACKAGE_NAME}.dxy)
|
|
|
|
set_target_properties(${CGAL_PACKAGE_NAME}_internal_doxygen_run PROPERTIES FOLDER Documentation/Packages)
|
|
|
|
#target moving the tag file into the read directory CGAL_DOC_TAG_DIR
|
|
if ( "${CGAL_PACKAGE_NAME}" STREQUAL "Documentation" )
|
|
set(CGAL_PACKAGE_TAGFILE "Manual.tag")
|
|
else()
|
|
set(CGAL_PACKAGE_TAGFILE "${CGAL_PACKAGE_NAME}.tag")
|
|
endif()
|
|
add_custom_target(${CGAL_PACKAGE_NAME}_copy_doc_tags
|
|
${CMAKE_COMMAND} -E copy
|
|
"${CGAL_DOC_TAG_GEN_DIR}/${CGAL_PACKAGE_TAGFILE}"
|
|
"${CGAL_DOC_TAG_DIR}/${CGAL_PACKAGE_TAGFILE}"
|
|
)
|
|
|
|
#add the doc target doing both the doc generation and then the tag file copy
|
|
add_custom_target(${CGAL_PACKAGE_NAME}_doc
|
|
${DOXYGEN_EXECUTABLE} ${CGAL_DOC_DXY_DIR}/${CGAL_PACKAGE_NAME}.dxy
|
|
COMMAND
|
|
${CMAKE_COMMAND} -E copy
|
|
"${CGAL_DOC_TAG_GEN_DIR}/${CGAL_PACKAGE_TAGFILE}"
|
|
"${CGAL_DOC_TAG_DIR}/${CGAL_PACKAGE_TAGFILE}"
|
|
)
|
|
|
|
# ${depend}_doc)
|
|
# don't do this for now
|
|
# foreach(depend ${DEPENDENCIES})
|
|
# add_dependencies(${CGAL_PACKAGE_NAME}_doc
|
|
# ${depend}_doc)
|
|
# endforeach()
|
|
|
|
endif()
|
|
endfunction()
|
|
|
|
find_package(Doxygen)
|
|
find_package(PythonInterp 2.6.7)
|
|
|
|
if(DOXYGEN_FOUND)
|
|
# set up the directories and variables
|
|
set(CGAL_DOC_MATHJAX_LOCATION "https://cdn.mathjax.org/mathjax/latest"
|
|
CACHE STRING "The location of MathJax to be used for the documentation.")
|
|
|
|
set(CGAL_DOC_OUTPUT_DIR "${CMAKE_BINARY_DIR}/doc_output")
|
|
file(MAKE_DIRECTORY "${CGAL_DOC_OUTPUT_DIR}")
|
|
|
|
option(CGAL_DOC_CREATE_LOGS "Write log files or print warnings and errors to cerr when building the doc." OFF)
|
|
|
|
if(CGAL_DOC_CREATE_LOGS)
|
|
set(CGAL_DOC_LOG_DIR "${CMAKE_BINARY_DIR}/doc_log")
|
|
file(MAKE_DIRECTORY "${CGAL_DOC_LOG_DIR}")
|
|
endif()
|
|
|
|
#we use two directories for the generation/reading of tag files to prevent issues
|
|
#if the targets are built in parallel
|
|
set(CGAL_DOC_TAG_GEN_DIR "${CMAKE_BINARY_DIR}/doc_gen_tags")
|
|
file(MAKE_DIRECTORY "${CGAL_DOC_TAG_GEN_DIR}")
|
|
set(CGAL_DOC_TAG_DIR "${CMAKE_BINARY_DIR}/doc_tags")
|
|
file(MAKE_DIRECTORY "${CGAL_DOC_TAG_DIR}")
|
|
set(CGAL_DOC_DXY_DIR "${CMAKE_BINARY_DIR}/doc_dxy")
|
|
file(MAKE_DIRECTORY "${CGAL_DOC_DXY_DIR}")
|
|
|
|
set(CGAL_DOC_RESOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/resources")
|
|
set(CGAL_DOC_BIBLIO_DIR "${CMAKE_CURRENT_LIST_DIR}/biblio")
|
|
set(CGAL_DOC_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}/scripts")
|
|
|
|
set(CGAL_DOC_HEADER ${CGAL_DOC_DXY_DIR}/header.html)
|
|
configure_file(${CGAL_DOC_RESOURCE_DIR}/header.html ${CGAL_DOC_HEADER} @ONLY)
|
|
set(CGAL_DOC_HEADER_PACKAGE ${CGAL_DOC_DXY_DIR}/header_package.html)
|
|
configure_file(${CGAL_DOC_RESOURCE_DIR}/header_package.html ${CGAL_DOC_HEADER_PACKAGE} @ONLY)
|
|
|
|
#Generate the bibtex file
|
|
#this is needed also for BaseDoxyfile.in
|
|
string(TIMESTAMP CGAL_BUILD_YEAR4 "%Y")
|
|
string(TIMESTAMP CGAL_BUILD_YEAR2 "%y")
|
|
string(TIMESTAMP CGAL_BUILD_MONTH "%m")
|
|
|
|
if (${CGAL_BUILD_MONTH} GREATER 6)
|
|
SET(CGAL_RELEASE_YEAR_ID "${CGAL_BUILD_YEAR2}b")
|
|
else()
|
|
SET(CGAL_RELEASE_YEAR_ID "${CGAL_BUILD_YEAR2}a")
|
|
endif()
|
|
|
|
## generate how_to_cite files
|
|
if(PYTHONINTERP_FOUND)
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE}
|
|
${CGAL_DOC_SCRIPT_DIR}/generate_how_to_cite.py
|
|
${CMAKE_SOURCE_DIR}
|
|
${CMAKE_BINARY_DIR}
|
|
RESULT_VARIABLE GENERATE_HOW_TO_CITE_RESULT)
|
|
if(NOT GENERATE_HOW_TO_CITE_RESULT EQUAL "0")
|
|
message(FATAL_ERROR "generate_how_to_cite did not exit correctly")
|
|
endif()
|
|
|
|
configure_file(${CMAKE_BINARY_DIR}/how_to_cite_cgal.bib.in ${CMAKE_BINARY_DIR}/how_to_cite_cgal.bib)
|
|
configure_file(${CMAKE_BINARY_DIR}/how_to_cite_cgal.txt.in ${CMAKE_BINARY_DIR}/how_to_cite_cgal.txt)
|
|
configure_file(${CMAKE_BINARY_DIR}/how_to_cite.html.in ${CMAKE_BINARY_DIR}/how_to_cite.html)
|
|
endif()
|
|
##
|
|
|
|
configure_file(${CGAL_DOC_RESOURCE_DIR}/BaseDoxyfile.in ${CGAL_DOC_DXY_DIR}/BaseDoxyfile)
|
|
|
|
set(CGAL_DOC_DOXY_DEFAULT "${CGAL_DOC_DXY_DIR}/BaseDoxyfile")
|
|
|
|
# pkglist_filter gets the path to the pkglist_filter of this source
|
|
# directory.
|
|
if(WIN32)
|
|
configure_file(${CGAL_DOC_SCRIPT_DIR}/pkglist_filter.bat ${CMAKE_BINARY_DIR}/pkglist_filter.bat)
|
|
endif()
|
|
configure_file(${CGAL_DOC_SCRIPT_DIR}/pkglist_filter ${CMAKE_BINARY_DIR}/pkglist_filter)
|
|
configure_file(${CGAL_DOC_SCRIPT_DIR}/pkglist_filter.py ${CMAKE_BINARY_DIR}/pkglist_filter.py)
|
|
|
|
foreach(package ${CGAL_CONFIGURED_PACKAGES_NAMES})
|
|
configure_doxygen_package(${package})
|
|
endforeach()
|
|
|
|
# hard-coded. this is not recognized as a package by the
|
|
# build-system, because it doesn't have a package_description subdir.
|
|
configure_doxygen_package("Miscellany")
|
|
|
|
# Add a custom target "doc"
|
|
add_custom_target(doc)
|
|
add_custom_target(doc_pre)
|
|
add_custom_target(doc_post)
|
|
|
|
# do the main package manually, it isn't part of ${CGAL_CONFIGURED_PACKAGES_NAMES}
|
|
configure_doxygen_package("Documentation")
|
|
set_target_properties(Documentation_doc PROPERTIES FOLDER Documentation)
|
|
|
|
# hard-code that doc depends on all packages
|
|
foreach(depend ${DOCUMENTATION_DEPENDENCIES})
|
|
add_dependencies(doc_pre ${depend}_internal_doxygen_run)
|
|
add_dependencies(doc_post ${depend}_copy_doc_tags)
|
|
add_dependencies(${depend}_copy_doc_tags doc_pre)
|
|
endforeach()
|
|
add_dependencies(doc_pre Documentation_internal_doxygen_run)
|
|
add_dependencies(doc_post Documentation_copy_doc_tags)
|
|
add_dependencies(Documentation_copy_doc_tags doc_pre)
|
|
|
|
#total level doc dependencies
|
|
add_dependencies(doc doc_post)
|
|
|
|
if(PYTHONINTERP_FOUND)
|
|
set(CGAL_DOC_TESTSUITE_SCRIPT "${CGAL_DOC_SCRIPT_DIR}/testsuite.py")
|
|
|
|
add_custom_target(doc_with_postprocessing
|
|
${PYTHON_EXECUTABLE} ${CGAL_DOC_SCRIPT_DIR}/html_output_post_processing.py --output ${CGAL_DOC_OUTPUT_DIR} --resources ${CGAL_DOC_RESOURCE_DIR}
|
|
)
|
|
add_dependencies(doc_with_postprocessing doc)
|
|
|
|
if(CGAL_DOC_CREATE_LOGS)
|
|
add_custom_target(Documentation_test
|
|
${PYTHON_EXECUTABLE} ${CGAL_DOC_TESTSUITE_SCRIPT} --output-dir ${CGAL_DOC_OUTPUT_DIR} --doc-log-dir ${CGAL_DOC_LOG_DIR}
|
|
)
|
|
add_dependencies(Documentation_test doc)
|
|
|
|
add_custom_target(Documentation_test_publish
|
|
${PYTHON_EXECUTABLE} ${CGAL_DOC_TESTSUITE_SCRIPT} --output-dir ${CGAL_DOC_OUTPUT_DIR} --doc-log-dir ${CGAL_DOC_LOG_DIR} --publish ${CGAL_DOC_PUBLISH_DIR} --do-copy-results
|
|
)
|
|
add_dependencies(Documentation_test_publish doc)
|
|
|
|
set(CGAL_DOC_VERSION_H "/tmp/version.h" CACHE PATH "Path to CGAL/version.h")
|
|
|
|
add_custom_target(doc_and_publish_testsuite
|
|
${PYTHON_EXECUTABLE} ${CGAL_DOC_TESTSUITE_SCRIPT} --output-dir ${CGAL_DOC_OUTPUT_DIR} --doc-log-dir ${CGAL_DOC_LOG_DIR} --publish ${CGAL_DOC_PUBLISH_DIR} --do-copy-results --cgal-version ${CGAL_DOC_VERSION_H} --version-to-keep 10
|
|
)
|
|
add_dependencies(doc_and_publish_testsuite doc_with_postprocessing)
|
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
# add_custom_target(doc) dummy to depend on all docs, require to run
|
|
# twice or something
|
|
endif()
|