2020-12-22 06:19:46 -05:00
|
|
|
set(SPHINX_BUILD "sphinx-build" CACHE STRING "Name/Path of the sphinx-build executable to use.")
|
|
|
|
set(SPHINX_FLAGS "" CACHE STRING "Flags to pass to sphinx-build")
|
|
|
|
|
|
|
|
find_program(BIN_SPHINX "${SPHINX_BUILD}")
|
|
|
|
|
|
|
|
if(NOT BIN_SPHINX)
|
|
|
|
message(FATAL_ERROR "sphinx-build executable '${SPHINX_BUILD}' not found.")
|
|
|
|
endif()
|
|
|
|
|
2018-12-14 03:34:31 -05:00
|
|
|
separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
|
2018-12-01 08:10:03 -05:00
|
|
|
|
2018-12-14 03:34:31 -05:00
|
|
|
set(doc_path "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
|
2019-04-30 15:52:17 -04:00
|
|
|
# Configures conf.py in the current folder and puts it in the build folder
|
|
|
|
configure_file(conf.py conf.py @ONLY)
|
|
|
|
|
2018-12-14 03:34:31 -05:00
|
|
|
# We want to run `sphinx-build` with the following builders
|
2020-12-22 06:29:26 -05:00
|
|
|
if (BUILD_DOC_HTML)
|
|
|
|
list(APPEND doc_builders "html")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_DOC_MAN)
|
|
|
|
list(APPEND doc_builders "man")
|
|
|
|
endif()
|
2018-12-14 03:34:31 -05:00
|
|
|
|
|
|
|
# Name of all documentation targets
|
|
|
|
set(doc_targets "")
|
|
|
|
|
|
|
|
foreach(builder ${doc_builders})
|
|
|
|
set(doc_target "doc_${builder}")
|
|
|
|
set(builder_log "builder-${builder}.log")
|
|
|
|
add_custom_target(${doc_target}
|
2020-12-21 21:43:06 -05:00
|
|
|
COMMAND ${BIN_SPHINX}
|
2018-12-14 03:34:31 -05:00
|
|
|
-b ${builder}
|
2019-04-30 15:52:17 -04:00
|
|
|
# conf.py dir
|
2018-12-14 03:34:31 -05:00
|
|
|
-c "${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
-d "${CMAKE_CURRENT_BINARY_DIR}/doctrees"
|
2021-01-07 08:19:48 -05:00
|
|
|
-n
|
2018-12-14 03:34:31 -05:00
|
|
|
${sphinx_flags}
|
2019-04-30 15:52:17 -04:00
|
|
|
# Documentation source file dir
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
# Output dir
|
2018-12-14 03:34:31 -05:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${builder}" > ${builder_log}
|
|
|
|
COMMENT "sphinx-build ${builder}: see doc/${builder_log}")
|
|
|
|
|
|
|
|
list(APPEND doc_targets ${doc_target})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# Dummy target that depends on all documentation targets
|
|
|
|
add_custom_target(doc ALL DEPENDS ${doc_targets})
|
|
|
|
|
2022-03-01 17:08:32 -05:00
|
|
|
if (BUILD_DOC_HTML)
|
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
|
2019-06-24 12:08:59 -04:00
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
2021-01-07 08:15:02 -05:00
|
|
|
COMPONENT doc
|
|
|
|
PATTERN ".buildinfo" EXCLUDE)
|
2022-03-01 17:08:32 -05:00
|
|
|
endif()
|
2018-12-01 08:10:03 -05:00
|
|
|
|
2021-01-07 08:19:59 -05:00
|
|
|
install(FILES ${CMAKE_SOURCE_DIR}/CHANGELOG.md
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
|
|
|
COMPONENT doc)
|
|
|
|
|
2021-10-05 07:07:19 -04:00
|
|
|
install(FILES ${CMAKE_CURRENT_LIST_DIR}/config.ini
|
|
|
|
DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples
|
|
|
|
COMPONENT doc)
|
|
|
|
|
2022-03-01 17:08:32 -05:00
|
|
|
if (BUILD_DOC_MAN)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.1
|
2019-06-24 12:08:59 -04:00
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
|
2018-12-02 13:17:26 -05:00
|
|
|
COMPONENT doc)
|
2019-10-03 16:42:47 -04:00
|
|
|
|
2022-03-01 17:08:32 -05:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar-msg.1
|
2022-01-24 07:26:58 -05:00
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
|
|
|
|
COMPONENT doc)
|
|
|
|
|
2022-03-01 17:08:32 -05:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/man/polybar.5
|
2019-10-03 16:42:47 -04:00
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man5
|
|
|
|
COMPONENT doc)
|
2022-03-01 17:08:32 -05:00
|
|
|
endif()
|
|
|
|
|