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