diff options
Diffstat (limited to 'doc/CMakeLists.txt')
-rw-r--r-- | doc/CMakeLists.txt | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 2777da68..46c3f73f 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -7,7 +7,7 @@ if (USE_DOXYGEN) find_package(Doxygen) - if(NOT DOXYGEN_FOUND) + if (NOT DOXYGEN_FOUND) message(FATAL_ERROR "Could not find doxygen. Reference documentation cannot be built.") endif() @@ -27,38 +27,55 @@ endif() ######################################################################## -if(NOT BUILD_DOCS) - add_custom_target(doc DEPENDS doc.doxygen) - return() +# BUILD_WEB_DOCS implies BUILD_DOCS +if (BUILD_WEB_DOCS) + set(BUILD_DOCS 1) endif() -set(info_files ledger3.texi ledger-mode.texi) +if (BUILD_DOCS) + find_program(MAKEINFO makeinfo) + find_program(TEXI2PDF texi2pdf) + find_program(TEX tex) + find_program(MAN2HTML man2html) + find_program(GROFF groff) + set(ledger_info_files ledger3.texi ledger-mode.texi) -find_program(MAKEINFO makeinfo) -find_program(TEXI2PDF texi2pdf) -find_program(MAN2HTML man2html) + if (NOT MAKEINFO) + message(WARNING "Could not find makeinfo. Info version of documentation cannot be built.") + endif() + + if (NOT TEXI2PDF OR NOT TEX) + message(WARNING "Could not find texi2pdf or tex. PDF version of documentation will not be built.") + endif() +endif() ######################################################################## -foreach(file ${info_files}) +foreach(file ${ledger_info_files}) get_filename_component(file_base ${file} NAME_WE) - if(BUILD_WEB_DOCS) - if(NOT MAKEINFO) - message(FATAL_ERROR "Could not find makeinfo. HTML version of documentation cannot be built.") - endif() + if (MAKEINFO) + add_custom_command(OUTPUT ${file_base}.info + COMMAND makeinfo --force --no-split -o ${file_base}.info ${CMAKE_CURRENT_SOURCE_DIR}/${file} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} + VERBATIM) + list(APPEND ledger_doc_files ${file_base}.info) + endif() + + if (BUILD_WEB_DOCS AND MAKEINFO) add_custom_command(OUTPUT ${file_base}.html COMMAND makeinfo --force --html --no-split -o ${file_base}.html ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.html) - endif(BUILD_WEB_DOCS) + endif() - if(NOT TEXI2PDF) - message(WARNING "Could not find texi2pdf. PDF version of documentation will not be built.") - else() + if (TEXI2PDF AND TEX) + if (BUILD_A4_PDF) + set(papersize --texinfo=@afourpaper) + endif() add_custom_command(OUTPUT ${file_base}.pdf - COMMAND texi2pdf -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} + COMMAND texi2pdf ${papersize} -b -q -o ${file_base}.pdf ${CMAKE_CURRENT_SOURCE_DIR}/${file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file} VERBATIM) list(APPEND ledger_doc_files ${file_base}.pdf) @@ -67,20 +84,26 @@ endforeach() ######################################################################## -if(BUILD_WEB_DOCS) +if (BUILD_WEB_DOCS) include(FindUnixCommands) - if(NOT BASH) + if (NOT BASH) message(FATAL_ERROR "Could not find bash. Unable to build documentation.") endif() - if(NOT MAN2HTML) - message(FATAL_ERROR "Could not find man2html. HTML version of man page cannot be built.") + if (MAN2HTML) + add_custom_command(OUTPUT ledger.1.html + COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.html) + elseif(GROFF) + add_custom_command(OUTPUT ledger.1.html + COMMAND ${BASH} -c "groff -mandoc -Thtml ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 > ledger.1.html" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 + VERBATIM) + list(APPEND ledger_doc_files ledger.1.html) + else() + message(FATAL_ERROR "Could not find man2html or groff. HTML version of man page cannot be built.") endif() - - add_custom_command(OUTPUT ledger.1.html - COMMAND ${BASH} -c "man2html ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 | tail -n+3 > ledger.1.html" - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 - VERBATIM) - list(APPEND ledger_doc_files ledger.1.html) endif(BUILD_WEB_DOCS) ######################################################################## @@ -91,16 +114,21 @@ add_custom_target(doc DEPENDS ${ledger_doc_files} doc.doxygen) include(GNUInstallDirs) -if(CMAKE_INSTALL_MANDIR) +if (CMAKE_INSTALL_MANDIR) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ledger.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) endif(CMAKE_INSTALL_MANDIR) -foreach(file ${info_files}) - get_filename_component(file_base ${file} NAME_WE) +foreach(file ${ledger_doc_files}) + get_filename_component(file_ext ${file} EXT) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file} - DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file_base}.pdf - DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc OPTIONAL) + if(file_ext STREQUAL ".info") + if(CMAKE_INSTALL_INFODIR) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} + DESTINATION ${CMAKE_INSTALL_INFODIR} COMPONENT doc) + endif() + elseif(CMAKE_INSTALL_DOCDIR) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} + DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT doc) + endif() endforeach() |