xref: /aosp_15_r20/external/llvm/docs/CMakeLists.txt (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker
2*9880d681SAndroid Build Coastguard Workerif (DOXYGEN_FOUND)
3*9880d681SAndroid Build Coastguard Workerif (LLVM_ENABLE_DOXYGEN)
4*9880d681SAndroid Build Coastguard Worker  set(abs_top_srcdir ${LLVM_MAIN_SRC_DIR})
5*9880d681SAndroid Build Coastguard Worker  set(abs_top_builddir ${LLVM_BINARY_DIR})
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker  if (HAVE_DOT)
8*9880d681SAndroid Build Coastguard Worker    set(DOT ${LLVM_PATH_DOT})
9*9880d681SAndroid Build Coastguard Worker  endif()
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker  if (LLVM_DOXYGEN_EXTERNAL_SEARCH)
12*9880d681SAndroid Build Coastguard Worker    set(enable_searchengine "YES")
13*9880d681SAndroid Build Coastguard Worker    set(searchengine_url "${LLVM_DOXYGEN_SEARCHENGINE_URL}")
14*9880d681SAndroid Build Coastguard Worker    set(enable_server_based_search "YES")
15*9880d681SAndroid Build Coastguard Worker    set(enable_external_search "YES")
16*9880d681SAndroid Build Coastguard Worker    set(extra_search_mappings "${LLVM_DOXYGEN_SEARCH_MAPPINGS}")
17*9880d681SAndroid Build Coastguard Worker  else()
18*9880d681SAndroid Build Coastguard Worker    set(enable_searchengine "NO")
19*9880d681SAndroid Build Coastguard Worker    set(searchengine_url "")
20*9880d681SAndroid Build Coastguard Worker    set(enable_server_based_search "NO")
21*9880d681SAndroid Build Coastguard Worker    set(enable_external_search "NO")
22*9880d681SAndroid Build Coastguard Worker    set(extra_search_mappings "")
23*9880d681SAndroid Build Coastguard Worker  endif()
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker  # If asked, configure doxygen for the creation of a Qt Compressed Help file.
26*9880d681SAndroid Build Coastguard Worker  option(LLVM_ENABLE_DOXYGEN_QT_HELP
27*9880d681SAndroid Build Coastguard Worker    "Generate a Qt Compressed Help file." OFF)
28*9880d681SAndroid Build Coastguard Worker  if (LLVM_ENABLE_DOXYGEN_QT_HELP)
29*9880d681SAndroid Build Coastguard Worker    set(LLVM_DOXYGEN_QCH_FILENAME "org.llvm.qch" CACHE STRING
30*9880d681SAndroid Build Coastguard Worker      "Filename of the Qt Compressed help file")
31*9880d681SAndroid Build Coastguard Worker    set(LLVM_DOXYGEN_QHP_NAMESPACE "org.llvm" CACHE STRING
32*9880d681SAndroid Build Coastguard Worker      "Namespace under which the intermediate Qt Help Project file lives")
33*9880d681SAndroid Build Coastguard Worker    set(LLVM_DOXYGEN_QHP_CUST_FILTER_NAME "${PACKAGE_STRING}" CACHE STRING
34*9880d681SAndroid Build Coastguard Worker      "See http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-filters")
35*9880d681SAndroid Build Coastguard Worker    set(LLVM_DOXYGEN_QHP_CUST_FILTER_ATTRS "${PACKAGE_NAME},${PACKAGE_VERSION}" CACHE STRING
36*9880d681SAndroid Build Coastguard Worker      "See http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes")
37*9880d681SAndroid Build Coastguard Worker    find_program(LLVM_DOXYGEN_QHELPGENERATOR_PATH qhelpgenerator
38*9880d681SAndroid Build Coastguard Worker      DOC "Path to the qhelpgenerator binary")
39*9880d681SAndroid Build Coastguard Worker    if (NOT LLVM_DOXYGEN_QHELPGENERATOR_PATH)
40*9880d681SAndroid Build Coastguard Worker      message(FATAL_ERROR "Failed to find qhelpgenerator binary")
41*9880d681SAndroid Build Coastguard Worker    endif()
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_generate_qhp "YES")
44*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qch_filename "${LLVM_DOXYGEN_QCH_FILENAME}")
45*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_namespace "${LLVM_DOXYGEN_QHP_NAMESPACE}")
46*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhelpgenerator_path "${LLVM_DOXYGEN_QHELPGENERATOR_PATH}")
47*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_cust_filter_name "${LLVM_DOXYGEN_QHP_CUST_FILTER_NAME}")
48*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_cust_filter_attrs "${LLVM_DOXYGEN_QHP_CUST_FILTER_ATTRS}")
49*9880d681SAndroid Build Coastguard Worker
50*9880d681SAndroid Build Coastguard Worker  else()
51*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_generate_qhp "NO")
52*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qch_filename "")
53*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_namespace "")
54*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhelpgenerator_path "")
55*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_cust_filter_name "")
56*9880d681SAndroid Build Coastguard Worker    set(llvm_doxygen_qhp_cust_filter_attrs "")
57*9880d681SAndroid Build Coastguard Worker  endif()
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker  option(LLVM_DOXYGEN_SVG
60*9880d681SAndroid Build Coastguard Worker    "Use svg instead of png files for doxygen graphs." OFF)
61*9880d681SAndroid Build Coastguard Worker  if (LLVM_DOXYGEN_SVG)
62*9880d681SAndroid Build Coastguard Worker    set(DOT_IMAGE_FORMAT "svg")
63*9880d681SAndroid Build Coastguard Worker  else()
64*9880d681SAndroid Build Coastguard Worker    set(DOT_IMAGE_FORMAT "png")
65*9880d681SAndroid Build Coastguard Worker  endif()
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
68*9880d681SAndroid Build Coastguard Worker    ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Worker  set(abs_top_srcdir)
71*9880d681SAndroid Build Coastguard Worker  set(abs_top_builddir)
72*9880d681SAndroid Build Coastguard Worker  set(DOT)
73*9880d681SAndroid Build Coastguard Worker  set(enable_searchengine)
74*9880d681SAndroid Build Coastguard Worker  set(searchengine_url)
75*9880d681SAndroid Build Coastguard Worker  set(enable_server_based_search)
76*9880d681SAndroid Build Coastguard Worker  set(enable_external_search)
77*9880d681SAndroid Build Coastguard Worker  set(extra_search_mappings)
78*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_generate_qhp)
79*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_qch_filename)
80*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_qhp_namespace)
81*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_qhelpgenerator_path)
82*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_qhp_cust_filter_name)
83*9880d681SAndroid Build Coastguard Worker  set(llvm_doxygen_qhp_cust_filter_attrs)
84*9880d681SAndroid Build Coastguard Worker  set(DOT_IMAGE_FORMAT)
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker  add_custom_target(doxygen-llvm
87*9880d681SAndroid Build Coastguard Worker    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
88*9880d681SAndroid Build Coastguard Worker    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
89*9880d681SAndroid Build Coastguard Worker    COMMENT "Generating llvm doxygen documentation." VERBATIM)
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Worker  if (LLVM_BUILD_DOCS)
92*9880d681SAndroid Build Coastguard Worker    add_dependencies(doxygen doxygen-llvm)
93*9880d681SAndroid Build Coastguard Worker  endif()
94*9880d681SAndroid Build Coastguard Worker
95*9880d681SAndroid Build Coastguard Worker  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
96*9880d681SAndroid Build Coastguard Worker    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
97*9880d681SAndroid Build Coastguard Worker      DESTINATION docs/html)
98*9880d681SAndroid Build Coastguard Worker  endif()
99*9880d681SAndroid Build Coastguard Workerendif()
100*9880d681SAndroid Build Coastguard Workerendif()
101*9880d681SAndroid Build Coastguard Worker
102*9880d681SAndroid Build Coastguard Workerif (LLVM_ENABLE_SPHINX)
103*9880d681SAndroid Build Coastguard Worker  if (SPHINX_FOUND)
104*9880d681SAndroid Build Coastguard Worker    include(AddSphinxTarget)
105*9880d681SAndroid Build Coastguard Worker    if (${SPHINX_OUTPUT_HTML})
106*9880d681SAndroid Build Coastguard Worker      add_sphinx_target(html llvm)
107*9880d681SAndroid Build Coastguard Worker    endif()
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Worker
110*9880d681SAndroid Build Coastguard Worker    if (${SPHINX_OUTPUT_MAN})
111*9880d681SAndroid Build Coastguard Worker      add_sphinx_target(man llvm)
112*9880d681SAndroid Build Coastguard Worker    endif()
113*9880d681SAndroid Build Coastguard Worker
114*9880d681SAndroid Build Coastguard Worker  endif()
115*9880d681SAndroid Build Coastguard Workerendif()
116*9880d681SAndroid Build Coastguard Worker
117*9880d681SAndroid Build Coastguard Workerlist(FIND LLVM_BINDINGS_LIST ocaml uses_ocaml)
118*9880d681SAndroid Build Coastguard Workerif( NOT uses_ocaml LESS 0 )
119*9880d681SAndroid Build Coastguard Worker  set(doc_targets
120*9880d681SAndroid Build Coastguard Worker        ocaml_llvm
121*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_all_backends
122*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_analysis
123*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_bitreader
124*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_bitwriter
125*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_executionengine
126*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_irreader
127*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_linker
128*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_target
129*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_ipo
130*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_passmgr_builder
131*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_scalar_opts
132*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_transform_utils
133*9880d681SAndroid Build Coastguard Worker        ocaml_llvm_vectorize
134*9880d681SAndroid Build Coastguard Worker      )
135*9880d681SAndroid Build Coastguard Worker
136*9880d681SAndroid Build Coastguard Worker  foreach(llvm_target ${LLVM_TARGETS_TO_BUILD})
137*9880d681SAndroid Build Coastguard Worker    list(APPEND doc_targets ocaml_llvm_${llvm_target})
138*9880d681SAndroid Build Coastguard Worker  endforeach()
139*9880d681SAndroid Build Coastguard Worker
140*9880d681SAndroid Build Coastguard Worker  set(odoc_files)
141*9880d681SAndroid Build Coastguard Worker  foreach( doc_target ${doc_targets} )
142*9880d681SAndroid Build Coastguard Worker    get_target_property(odoc_file ${doc_target} OCAML_ODOC)
143*9880d681SAndroid Build Coastguard Worker    list(APPEND odoc_files -load ${odoc_file})
144*9880d681SAndroid Build Coastguard Worker  endforeach()
145*9880d681SAndroid Build Coastguard Worker
146*9880d681SAndroid Build Coastguard Worker  add_custom_target(ocaml_doc
147*9880d681SAndroid Build Coastguard Worker    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
148*9880d681SAndroid Build Coastguard Worker    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
149*9880d681SAndroid Build Coastguard Worker    COMMAND ${OCAMLFIND} ocamldoc -d ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
150*9880d681SAndroid Build Coastguard Worker                                  -sort -colorize-code -html ${odoc_files}
151*9880d681SAndroid Build Coastguard Worker    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_ocamldoc/style.css
152*9880d681SAndroid Build Coastguard Worker                                     ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html)
153*9880d681SAndroid Build Coastguard Worker
154*9880d681SAndroid Build Coastguard Worker  add_dependencies(ocaml_doc ${doc_targets})
155*9880d681SAndroid Build Coastguard Worker
156*9880d681SAndroid Build Coastguard Worker  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
157*9880d681SAndroid Build Coastguard Worker    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
158*9880d681SAndroid Build Coastguard Worker      DESTINATION docs/ocaml/html)
159*9880d681SAndroid Build Coastguard Worker  endif()
160*9880d681SAndroid Build Coastguard Workerendif()
161