From b58edf3cb8bc56f09b2011df931a3fa5e40c66ce Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 28 Jul 2021 10:23:50 -0700 Subject: Docs: Add epub targets for the guides. Add user_guide_epub and developer_guide_epub targets that generate EPUB versions of the User's Guide and Developer's Guide. Ping #17494. --- cmake/modules/FindAsciidoctor.cmake | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'cmake/modules') diff --git a/cmake/modules/FindAsciidoctor.cmake b/cmake/modules/FindAsciidoctor.cmake index a452d4af22..f9d61e5c80 100644 --- a/cmake/modules/FindAsciidoctor.cmake +++ b/cmake/modules/FindAsciidoctor.cmake @@ -177,6 +177,53 @@ if(ASCIIDOCTOR_EXECUTABLE) endif(ASCIIDOCTOR_PDF_EXECUTABLE) + FIND_PROGRAM(ASCIIDOCTOR_EPUB_EXECUTABLE + NAMES + asciidoctorj + asciidoctor-epub3 + PATHS + /bin + /usr/bin + /usr/local/bin + ${CHOCOLATEY_BIN_PATH} + DOC "Path to Asciidoctor EPUB3 or AsciidoctorJ" + ) + + if(ASCIIDOCTOR_EPUB_EXECUTABLE) + + set(_asciidoctor_epub_common_command + ${CMAKE_COMMAND} -E env TZ=UTC ASCIIDOCTORJ_OPTS="${_asciidoctorj_opts}" + ${ASCIIDOCTOR_EPUB_EXECUTABLE} + --backend epub3 + ${_asciidoctor_common_args} + ) + + MACRO(ASCIIDOCTOR2EPUB _asciidocsource) + GET_FILENAME_COMPONENT(_source_base_name ${_asciidocsource} NAME_WE ) + set(_output_epub ${_source_base_name}.epub) + + ADD_CUSTOM_COMMAND( + OUTPUT + ${_output_epub} + COMMAND ${_asciidoctor_epub_common_command} + --out-file ${_output_epub} + ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource} + DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource} + ${ARGN} + ) + add_custom_target(generate_${_output_epub} DEPENDS ${_output_epub}) + set_asciidoctor_target_properties(generate_${_output_epub}) + unset(_output_epub) + ENDMACRO() + + else(ASCIIDOCTOR_EPUB_EXECUTABLE) + + MACRO(ASCIIDOCTOR2EPUB _asciidocsource) + ENDMACRO() + + endif(ASCIIDOCTOR_EPUB_EXECUTABLE) + endif(ASCIIDOCTOR_EXECUTABLE) include( FindPackageHandleStandardArgs ) -- cgit v1.2.3