summaryrefslogtreecommitdiffstats
path: root/Utilities/Sphinx
diff options
context:
space:
mode:
authorHenryk Paluch <henryk.paluch@pickering.cz>2021-02-19 12:39:28 (GMT)
committerBrad King <brad.king@kitware.com>2021-03-01 20:28:10 (GMT)
commit5302073010eaf74fbc577cd53c62004545bc291e (patch)
tree263f9b27b6b3b6fbcea6b2cf9c2c9c15986f9388 /Utilities/Sphinx
parent11506eb1297ee50a213bad6beb943ba41556c58e (diff)
downloadCMake-5302073010eaf74fbc577cd53c62004545bc291e.zip
CMake-5302073010eaf74fbc577cd53c62004545bc291e.tar.gz
CMake-5302073010eaf74fbc577cd53c62004545bc291e.tar.bz2
Help: Add option to generate docs with latexpdf
Diffstat (limited to 'Utilities/Sphinx')
-rw-r--r--Utilities/Sphinx/CMakeLists.txt65
1 files changed, 48 insertions, 17 deletions
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index 69f85d9..32efd48 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -22,6 +22,7 @@ option(SPHINX_MAN "Build man pages with Sphinx" OFF)
option(SPHINX_HTML "Build html help with Sphinx" OFF)
option(SPHINX_SINGLEHTML "Build html single page help with Sphinx" OFF)
option(SPHINX_QTHELP "Build Qt help with Sphinx" OFF)
+option(SPHINX_LATEXPDF "Build PDF help with Sphinx using LaTeX" OFF)
option(SPHINX_TEXT "Build text help with Sphinx (not installed)" OFF)
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
@@ -33,7 +34,7 @@ separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
mark_as_advanced(SPHINX_TEXT)
mark_as_advanced(SPHINX_FLAGS)
-if(NOT SPHINX_INFO AND NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
+if(NOT SPHINX_INFO AND NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT AND NOT SPHINX_LATEXPDF)
return()
elseif(NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
@@ -117,28 +118,51 @@ if(SPHINX_QTHELP)
${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp
)
endif()
-
+if(SPHINX_LATEXPDF)
+ list(APPEND doc_formats latexpdf)
+endif()
set(doc_format_outputs "")
set(doc_format_last "")
foreach(format ${doc_formats})
set(doc_format_output "doc_format_${format}")
set(doc_format_log "build-${format}.log")
- add_custom_command(
- OUTPUT ${doc_format_output}
- COMMAND ${SPHINX_EXECUTABLE}
- -c ${CMAKE_CURRENT_BINARY_DIR}
- -d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
- -b ${format}
- ${sphinx_flags}
- ${CMake_SOURCE_DIR}/Help
- ${CMAKE_CURRENT_BINARY_DIR}/${format}
- > ${doc_format_log} # log stdout, pass stderr
- ${${format}_extra_commands}
- DEPENDS ${doc_format_last}
- COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
- VERBATIM
- )
+ if(format STREQUAL "latexpdf")
+ # This format does not use builder (-b) but make_mode (-M) which expects
+ # arguments in peculiar order
+ add_custom_command(
+ OUTPUT ${doc_format_output}
+ COMMAND ${SPHINX_EXECUTABLE}
+ -M ${format}
+ ${CMake_SOURCE_DIR}/Help
+ ${CMAKE_CURRENT_BINARY_DIR}/${format}
+ -c ${CMAKE_CURRENT_BINARY_DIR}
+ -d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
+ ${sphinx_flags}
+ > ${doc_format_log} # log stdout, pass stderr
+ ${${format}_extra_commands}
+ DEPENDS ${doc_format_last}
+ COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
+ VERBATIM
+ )
+ else()
+ # other formats use standard builder (-b) mode
+ add_custom_command(
+ OUTPUT ${doc_format_output}
+ COMMAND ${SPHINX_EXECUTABLE}
+ -c ${CMAKE_CURRENT_BINARY_DIR}
+ -d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
+ -b ${format}
+ ${sphinx_flags}
+ ${CMake_SOURCE_DIR}/Help
+ ${CMAKE_CURRENT_BINARY_DIR}/${format}
+ > ${doc_format_log} # log stdout, pass stderr
+ ${${format}_extra_commands}
+ DEPENDS ${doc_format_last}
+ COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
+ VERBATIM
+ )
+ endif()
set_property(SOURCE ${doc_format_output} PROPERTY SYMBOLIC 1)
list(APPEND doc_format_outputs ${doc_format_output})
set(doc_format_last ${doc_format_output})
@@ -219,3 +243,10 @@ if(SPHINX_QTHELP)
DESTINATION ${CMAKE_DOC_DIR} ${COMPONENT}
)
endif()
+
+if(SPHINX_LATEXPDF)
+ CMake_OPTIONAL_COMPONENT(sphinx-latexpdf)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/latexpdf/latex/CMake.pdf
+ DESTINATION ${CMAKE_DOC_DIR} ${COMPONENT}
+ )
+endif()