-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (87 loc) · 4.22 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
cmake_minimum_required(VERSION 3.20)
project(Galois)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
# BUILD_DOCS could be passed from Galois root
set(DOC_TYPES "external" "internal")
if(NOT BUILD_DOCS)
set(BUILD_DOCS "external" CACHE STRING "Documentation build type: external (default), internal. `external` docs hide '*-draft*' and '*-internal* documentation pages and directories when building documentation.")
set_property(CACHE BUILD_DOCS PROPERTY STRINGS DOC_TYPES)
endif()
if(NOT (BUILD_DOCS IN_LIST DOC_TYPES))
message(STATUS "Unknown documentation build type: '${BUILD_DOCS}'; default to 'external'")
set(BUILD_DOCS "external")
endif()
# GALOIS_ROOT could be passed from Galois root
if(NOT GALOIS_ROOT)
if(DEFINED ENV{GALOIS_ROOT})
set(GALOIS_ROOT $ENV{GALOIS_ROOT})
else()
set(GALOIS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. CACHE PATH "Path to the root of the Galois source repo")
endif()
message(STATUS "Galois rooted at ${GALOIS_ROOT}")
endif()
# Use both "doc" and "docs" to make people with different mental conventions happy
add_custom_target(docs)
add_custom_target(doc)
add_dependencies(doc docs)
find_package(Doxygen REQUIRED)
# TODO: double check the list of directories here
set(DOXYFILE_SOURCE_DIR_LIST
${PROJECT_SOURCE_DIR}/doxygen
${GALOIS_ROOT}/libgalois/include
${GALOIS_ROOT}/libgalois/src
${GALOIS_ROOT}/libdist
${GALOIS_ROOT}/libcusp
${GALOIS_ROOT}/libgluon
)
# DOXYFILE_SOURCE_DIR
list(JOIN DOXYFILE_SOURCE_DIR_LIST "\" \"" DOXYFILE_SOURCE_DIR)
string(CONCAT DOXYFILE_SOURCE_DIR "\"" ${DOXYFILE_SOURCE_DIR} "\"")
# DOXYFILE_OUTPUT_DIR
set(DOXYFILE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
if(BUILD_DOCS STREQUAL "internal")
# EXTRACT_ANON_NSPACES
set(DOXYFILE_EXTRACT_ANON_NSPACES "YES")
# MACRO_EXPANSION
set(DOXYFILE_MACRO_EXPANSION "YES")
set(DOXYFILE_EXPAND_ONLY_PREDEF "YES")
set(DOXYFILE_EXPAND_AS_DEFINED "GALOIS_ATTRIBUTE_NOINLINE")
else()
# EXCLUDE_SYMBOLS
set(DOXYFILE_EXCLUDE_SYMBOLS "*::internal")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.in @ONLY)
add_custom_target(doxygen_docs
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.in
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DOXYFILE_SOURCE_DIR_LIST} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.in
COMMENT "Generate documentation with Doxygen using ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.in"
)
add_dependencies(docs doxygen_docs)
find_package(Sphinx)
if(SPHINX_FOUND AND BUILD_DOCS STREQUAL "external") # breathe does not support features like anonymous namespaces
set(SPHINX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
cmake_path(APPEND CMAKE_CURRENT_BINARY_DIR "sphinx" OUTPUT_VARIABLE SPHINX_DEFAULT_BUILD_DIR)
set(SPHINX_BUILD_DIR ${SPHINX_DEFAULT_BUILD_DIR} CACHE PATH "Sphinx doc build path")
cmake_path(APPEND DOXYFILE_OUTPUT_DIR "xml" OUTPUT_VARIABLE DOXYFILE_XML_OUTPUT_DIR)
cmake_path(APPEND SPHINX_SOURCE_DIR "api" OUTPUT_VARIABLE BREATHE_APIDOC_DIR)
add_custom_target(breathe_apidoc # ALL
COMMAND breathe-apidoc -q -o ${BREATHE_APIDOC_DIR} ${DOXYFILE_XML_OUTPUT_DIR}
COMMAND rm -rf ${BREATHE_APIDOC_DIR}/namespace* # Ad hoc to faulty namespace recognition
# COMMAND find ${BREATHE_APIDOC_DIR} -iname "*anonymous__namespace*" -delete # Ad hoc: breathe does not support anon nspaces
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DOXYFILE_XML_OUTPUT_DIR}
COMMENT "Generating API references for Sphinx"
)
set_property(TARGET breathe_apidoc APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${BREATHE_APIDOC_DIR})
add_dependencies(breathe_apidoc doxygen_docs)
add_custom_target(sphinx_docs # ALL
COMMAND ${SPHINX_EXECUTABLE} -b html -D breathe_projects.Galois=${DOXYFILE_XML_OUTPUT_DIR} ${SPHINX_SOURCE_DIR} ${SPHINX_BUILD_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/conf.py ${SPHINX_SOURCE_DIR} ${DOXYFILE_XML_OUTPUT_DIR}
COMMENT "Generating documentation with Sphinx"
)
add_dependencies(sphinx_docs breathe_apidoc)
add_dependencies(docs sphinx_docs)
endif()