Warning, /frameworks/extra-cmake-modules/docs/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #=============================================================================
0002 # SPDX-FileCopyrightText: 2000-2013 Kitware, Inc.
0003 # SPDX-FileCopyrightText: 2014-2015 Alex Merry <alex.merry@kde.org>
0004 #
0005 # SPDX-License-Identifier: BSD-3-Clause
0006 #=============================================================================
0007
0008 include(CMakeDependentOption)
0009
0010 find_package(Sphinx 1.2 MODULE)
0011 set_package_properties(
0012 Sphinx
0013 PROPERTIES
0014 URL "https://www.sphinx-doc.org/"
0015 DESCRIPTION "Tool to generate documentation."
0016 TYPE OPTIONAL
0017 PURPOSE "Required to build documentation for Extra CMake Modules."
0018 )
0019
0020 find_package(QCollectionGenerator MODULE)
0021 set_package_properties(
0022 QCollectionGenerator
0023 PROPERTIES
0024 URL "https://www.qt.io/"
0025 DESCRIPTION "Qt help collection generator."
0026 TYPE OPTIONAL
0027 PURPOSE "Required to build Extra CMake Modules documentation in Qt Help format."
0028 )
0029
0030 cmake_dependent_option(
0031 BUILD_HTML_DOCS "Build html help with Sphinx" ON
0032 "Sphinx_FOUND" OFF
0033 )
0034 add_feature_info(BUILD_HTML_DOCS BUILD_HTML_DOCS "Generate HTML documentation for installed modules.")
0035
0036 cmake_dependent_option(
0037 BUILD_MAN_DOCS "Build man pages with Sphinx" ON
0038 "Sphinx_FOUND" OFF
0039 )
0040 add_feature_info(BUILD_MAN_DOCS BUILD_MAN_DOCS "Generate man page documentation for installed modules.")
0041
0042 cmake_dependent_option(
0043 BUILD_QTHELP_DOCS "Build Qt help with Sphinx" OFF
0044 "Sphinx_FOUND;QCollectionGenerator_FOUND" OFF
0045 )
0046 add_feature_info(BUILD_QTHELP_DOCS BUILD_QTHELP_DOCS "Generate QtHelp documentation for installed modules.")
0047
0048
0049 set(doc_formats "")
0050 if(BUILD_HTML_DOCS)
0051 list(APPEND doc_formats html)
0052 endif()
0053 if(BUILD_MAN_DOCS)
0054 list(APPEND doc_formats man)
0055 endif()
0056 if(BUILD_QTHELP_DOCS)
0057 list(APPEND doc_formats qthelp)
0058 set(qthelp_extra_commands
0059 COMMAND
0060 QCollectionGenerator::Generator
0061 ${CMAKE_CURRENT_BINARY_DIR}/qthelp/ExtraCMakeModules.qhcp
0062 )
0063 endif()
0064
0065 if(NOT doc_formats)
0066 return()
0067 endif()
0068
0069 if (Sphinx_VERSION VERSION_LESS 1.3)
0070 set(sphinx_theme default)
0071 else()
0072 set(sphinx_theme classic)
0073 endif()
0074 configure_file(sphinx/conf.py.in conf.py @ONLY)
0075 configure_file(sphinx/ecm.css.in static/ecm.css)
0076
0077
0078 set(doc_format_outputs "")
0079 set(doc_format_last "")
0080 foreach(format ${doc_formats})
0081 set(doc_format_output "doc_format_${format}")
0082 set(doc_format_log "build-${format}.log")
0083 add_custom_command(
0084 OUTPUT ${doc_format_output}
0085 COMMAND
0086 Sphinx::Build
0087 -D man_make_section_directory=0
0088 -c ${CMAKE_CURRENT_BINARY_DIR}
0089 -d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
0090 -b ${format}
0091 ${CMAKE_CURRENT_SOURCE_DIR}
0092 ${CMAKE_CURRENT_BINARY_DIR}/${format}
0093 > ${doc_format_log} # log stdout, pass stderr
0094 ${${format}_extra_commands}
0095 DEPENDS ${doc_format_last}
0096 COMMENT "sphinx-build ${format}: see ${CMAKE_CURRENT_BINARY_DIR}/${doc_format_log}"
0097 VERBATIM
0098 )
0099 set_property(SOURCE ${doc_format_output} PROPERTY SYMBOLIC 1)
0100 list(APPEND doc_format_outputs ${doc_format_output})
0101 set(doc_format_last ${doc_format_output})
0102 endforeach()
0103
0104 add_custom_target(documentation ALL DEPENDS ${doc_format_outputs})
0105
0106 if(BUILD_MAN_DOCS)
0107 file(GLOB man_rst RELATIVE ${ECM_SOURCE_DIR}/docs/manual
0108 ${ECM_SOURCE_DIR}/docs/manual/*.[1-9].rst)
0109 foreach(m ${man_rst})
0110 if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$")
0111 set(name "${CMAKE_MATCH_1}")
0112 set(sec "${CMAKE_MATCH_2}")
0113 install(
0114 FILES ${CMAKE_CURRENT_BINARY_DIR}/man/${name}.${sec}
0115 DESTINATION ${MAN_INSTALL_DIR}/man${sec}
0116 )
0117 endif()
0118 endforeach()
0119 endif()
0120 if(BUILD_HTML_DOCS)
0121 install(
0122 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
0123 DESTINATION ${DOC_INSTALL_DIR}
0124 PATTERN .buildinfo EXCLUDE
0125 PATTERN objects.inv EXCLUDE
0126 )
0127 endif()
0128 if(BUILD_QTHELP_DOCS)
0129 install(
0130 FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/ExtraCMakeModules.qch
0131 DESTINATION ${DOC_INSTALL_DIR}
0132 )
0133 endif()