find_program(ASCIIDOCTOR_EXE asciidoctor)
mark_as_advanced(ASCIIDOCTOR_EXE) # Don't show in CMake UIs
+find_program(PANDOC_EXE pandoc)
+mark_as_advanced(PANDOC_EXE) # Don't show in CMake UIs
+
if(NOT ASCIIDOCTOR_EXE)
message(WARNING "Could not find asciidoctor; documentation will not be generated")
else()
- function(generate_doc backend adoc_file output_file)
+ function(generate_doc type adoc_file output_file)
add_custom_command(
OUTPUT "${output_file}"
COMMAND
- ${ASCIIDOCTOR_EXE}
- -o "${output_file}"
- -a revnumber="${CCACHE_VERSION}"
- -a icons=font
- -a toc=left
- -a sectanchors
- -a stylesheet="${CMAKE_CURRENT_SOURCE_DIR}/ccache-doc.css"
- -b "${backend}"
- "${CMAKE_SOURCE_DIR}/${adoc_file}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate-${type}"
+ "${ASCIIDOCTOR_EXE}"
+ "${PANDOC_EXE}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/ccache-doc.css"
+ "${CCACHE_VERSION}"
+ "${CMAKE_SOURCE_DIR}/${adoc_file}"
+ "${output_file}"
MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/${adoc_file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/ccache-doc.css"
)
- if(${backend} STREQUAL manpage)
- # Convert monospace to bold since that's typically rendered better when
- # viewing the man page.
- add_custom_command(
- OUTPUT "${output_file}"
- COMMAND perl -pi -e "'s!\\\\f\\(CR(.*?)\\\\fP!\\\\fB\\1\\\\fP!g'" "${output_file}"
- APPEND
- )
- endif()
- if("${backend}" STREQUAL manpage)
+
+ if("${type}" STREQUAL manpage)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${output_file}"
DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
)
- else()
+ elseif("${type}" STREQUAL html)
set(html_doc_files "${html_doc_files}" "${output_file}" PARENT_SCOPE)
install(
- FILES "${CMAKE_SOURCE_DIR}/${adoc_file}" "${CMAKE_CURRENT_BINARY_DIR}/${output_file}"
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${output_file}"
+ DESTINATION "${CMAKE_INSTALL_DOCDIR}"
+ )
+ elseif("${type}" STREQUAL markdown)
+ set(markdown_doc_files "${markdown_doc_files}" "${output_file}" PARENT_SCOPE)
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${output_file}"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
)
endif()
generate_doc(html doc/NEWS.adoc NEWS.html)
add_custom_target(doc-html DEPENDS "${html_doc_files}")
+ if(PANDOC_EXE)
+ #
+ # Markdown documentation
+ #
+ generate_doc(markdown LICENSE.adoc LICENSE.md)
+ generate_doc(markdown doc/AUTHORS.adoc AUTHORS.md)
+ generate_doc(markdown doc/MANUAL.adoc MANUAL.md)
+ generate_doc(markdown doc/NEWS.adoc NEWS.md)
+ add_custom_target(doc-markdown DEPENDS "${markdown_doc_files}")
+ else()
+ message(WARNING "Could not find pandoc; markdown documentation will not be generated")
+ endif()
+
#
# Man page
#
add_custom_target(doc-man-page DEPENDS ccache.1)
add_custom_target(doc ALL DEPENDS doc-html doc-man-page)
+ if(PANDOC_EXE)
+ add_dependencies(doc doc-markdown)
+ endif()
endif()
Optional:
-- GNU Bourne Again SHell (bash) for tests.
-- [Asciidoctor](https://asciidoctor.org) to build the HTML documentation.
-- [Python](https://www.python.org) to debug and run the performance test suite.
+- [Bash](https://www.gnu.org/software/bash) and [Python](https://www.python.org)
+ to run the test suite.
+- [Asciidoctor](https://asciidoctor.org) to build documentation in HTML and
+ Markdown format.
+- [Pandoc](https://pandoc.org) to build documentation in Markdown format.
See also [CI configurations](../.github/workflows/build.yaml) for regularly
tested build setups, including cross-compilation and dependencies required in