xref: /llvm-project/lldb/docs/CMakeLists.txt (revision 622df0ee9226b90e924538909337d55333d5d2fa)
1include(FindDoxygen)
2
3if(DOXYGEN_FOUND)
4  set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR}/..)
5  set(DOT dot)
6  set(PACKAGE_VERSION mainline)
7  set(abs_top_builddir ..)
8  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
9  ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
10
11  add_custom_target(lldb-cpp-doc
12    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
13    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
14    COMMENT "Generating LLDB C++ API reference with Doxygen" VERBATIM
15  )
16  set_target_properties(lldb-cpp-doc PROPERTIES FOLDER "LLDB/Docs")
17endif()
18
19if (LLVM_ENABLE_SPHINX)
20  include(AddSphinxTarget)
21endif()
22
23if (LLDB_ENABLE_PYTHON AND SPHINX_FOUND)
24  if (${SPHINX_OUTPUT_HTML})
25    # Pretend that the SWIG generated API is a Python package.
26    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb)
27    get_target_property(lldb_bindings_dir swig_wrapper_python BINARY_DIR)
28    add_custom_target(lldb-python-doc-package
29      COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_bindings_dir}/lldb.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
30      COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins"
31      COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
32      COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
33      COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/operating_system.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
34      COMMAND "${CMAKE_COMMAND}" -E copy "${LLDB_SOURCE_DIR}/examples/python/templates/scripted_thread_plan.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/plugins/"
35      COMMENT "Copying lldb.py to pretend its a Python package.")
36
37    add_dependencies(lldb-python-doc-package swig_wrapper_python lldb-python)
38
39    # FIXME: Don't treat Sphinx warnings as errors. The files generated by
40    # automodapi are full of warnings (partly caused by SWIG, our documentation
41    # and probably also automodapi itself), so those warnings need to be fixed
42    # first before we can turn this on.
43    set(SPHINX_WARNINGS_AS_ERRORS Off)
44
45    # The sphinx config needs to know where the generated LLDB Python module is.
46    # There is no way to pass a variable into our sphinx config, so just pass
47    # the path to the module via the LLDB_SWIG_MODULE environment variable.
48    add_sphinx_target(html lldb ENV_VARS "LLDB_SWIG_MODULE=${CMAKE_CURRENT_BINARY_DIR}")
49    # Sphinx does not reliably update the custom CSS files, so force
50    # a clean rebuild of the documentation every time.
51    add_custom_target(clean-lldb-html COMMAND "${CMAKE_COMMAND}" -E
52      remove_directory ${CMAKE_CURRENT_BINARY_DIR}/html)
53    add_dependencies(docs-lldb-html swig_wrapper_python
54                     lldb-python-doc-package clean-lldb-html)
55  endif()
56
57  if (${SPHINX_OUTPUT_MAN})
58    add_sphinx_target(man lldb)
59  endif()
60endif()
61