Skip to content
Snippets Groups Projects
Commit 53020730 authored by Henryk Paluch's avatar Henryk Paluch Committed by Brad King
Browse files

Help: Add option to generate docs with latexpdf

parent 11506eb1
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,9 @@ if(CMake_INSTALL_COMPONENTS)
if(SPHINX_QTHELP)
list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-qthelp)
endif()
if(SPHINX_LATEXPDF)
list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-latexpdf)
endif()
if(CMake_BUILD_DEVELOPER_REFERENCE)
if(CMake_BUILD_DEVELOPER_REFERENCE_HTML)
list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-html)
......
......@@ -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()
......@@ -84,6 +84,7 @@ cmake_sphinx_info=""
cmake_sphinx_man=""
cmake_sphinx_html=""
cmake_sphinx_qthelp=""
cmake_sphinx_latexpdf=""
cmake_sphinx_build=""
cmake_sphinx_flags=""
......@@ -662,6 +663,7 @@ Configuration:
--sphinx-man build man pages with Sphinx
--sphinx-html build html help with Sphinx
--sphinx-qthelp build qch help with Sphinx
--sphinx-latexpdf build PDF with Sphinx using LaTeX
--sphinx-build=<sb> use <sb> as the sphinx-build executable
--sphinx-flags=<flags> pass <flags> to sphinx-build executable
......@@ -926,6 +928,7 @@ while test $# != 0; do
--sphinx-man) cmake_sphinx_man="1" ;;
--sphinx-html) cmake_sphinx_html="1" ;;
--sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
--sphinx-latexpdf) cmake_sphinx_latexpdf="1" ;;
--sphinx-build=*) cmake_sphinx_build=`cmake_arg "$1"` ;;
--sphinx-flags=*) cmake_sphinx_flags=`cmake_arg "$1"` ;;
--help) cmake_usage ;;
......@@ -1917,6 +1920,11 @@ if test "x${cmake_sphinx_qthelp}" != "x"; then
set (SPHINX_QTHELP "'"${cmake_sphinx_qthelp}"'" CACHE BOOL "Build qch help with Sphinx" FORCE)
' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
fi
if test "x${cmake_sphinx_latexpdf}" != "x"; then
echo '
set (SPHINX_LATEXPDF "'"${cmake_sphinx_latexpdf}"'" CACHE BOOL "Build PDF help with Sphinx using LaTeX" FORCE)
' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
fi
if test "x${cmake_sphinx_build}" != "x"; then
echo '
set (SPHINX_EXECUTABLE "'"${cmake_sphinx_build}"'" CACHE FILEPATH "Location of Qt sphinx-build" FORCE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment