From: Joel Rosdahl Date: Wed, 27 Aug 2025 18:53:45 +0000 (+0200) Subject: build: Improve installation of documentation X-Git-Tag: v4.12~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c96fbe06867f40e7bb6e5fc07023c11c3774a1d;p=thirdparty%2Fccache.git build: Improve installation of documentation - Make HTML and man page part of "cmake --install". - Make modifications of man page in-place to avoid leaving a .tmp file behind. --- diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 997e49d2..1d860f2b 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -5,7 +5,6 @@ if(NOT ASCIIDOCTOR_EXE) message(WARNING "Could not find asciidoctor; documentation will not be generated") else() function(generate_doc backend adoc_file output_file) - get_filename_component(base_name "${adoc_file}" NAME_WE) add_custom_command( OUTPUT "${output_file}" COMMAND @@ -21,7 +20,27 @@ else() MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/${adoc_file}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/ccache-doc.css" ) - set(doc_files "${doc_files}" "${output_file}" PARENT_SCOPE) + 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) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${output_file}" + DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" + ) + else() + set(html_doc_files "${html_doc_files}" "${output_file}" PARENT_SCOPE) + install( + FILES "${CMAKE_SOURCE_DIR}/${adoc_file}" "${CMAKE_CURRENT_BINARY_DIR}/${output_file}" + DESTINATION "${CMAKE_INSTALL_DOCDIR}" + ) + endif() endfunction() # @@ -31,23 +50,12 @@ else() generate_doc(html doc/AUTHORS.adoc AUTHORS.html) generate_doc(html doc/MANUAL.adoc MANUAL.html) generate_doc(html doc/NEWS.adoc NEWS.html) - add_custom_target(doc-html DEPENDS "${doc_files}") + add_custom_target(doc-html DEPENDS "${html_doc_files}") # # Man page # - generate_doc(manpage doc/MANUAL.adoc ccache.1.tmp) - add_custom_command( - OUTPUT ccache.1 - # Convert monospace to bold since that's typically rendered better when - # viewing the man page. - COMMAND perl -pe "'s!\\\\f\\(CR(.*?)\\\\fP!\\\\fB\\1\\\\fP!g'" ccache.1.tmp >ccache.1 - MAIN_DEPENDENCY ccache.1.tmp - ) - install( - FILES "${CMAKE_CURRENT_BINARY_DIR}/ccache.1" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man1" - ) + generate_doc(manpage doc/MANUAL.adoc ccache.1) add_custom_target(doc-man-page DEPENDS ccache.1) add_custom_target(doc ALL DEPENDS doc-html doc-man-page)