CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 2 or (at your option)
  6. # version 3 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. find_program(ASCIIDOCTOR_EXE asciidoctor)
  16. if(NOT ASCIIDOCTOR_EXE)
  17. message(FATAL_ERROR "asciidoctor is required to build documentation")
  18. endif()
  19. message(STATUS "Using asciidoctor: ${ASCIIDOCTOR_EXE}")
  20. set(DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  21. set(OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
  22. set(REV -a revnumber=${KEEPASSXC_VERSION})
  23. # Build html documentation on all platforms
  24. # NOTE: Combine into one long command to prevent MSVC from failing to build all docs
  25. file(GLOB doc_depends ${DOC_DIR}/*.adoc ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*)
  26. add_custom_command(
  27. OUTPUT KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html
  28. COMMAND
  29. ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc &&
  30. ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc &&
  31. ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_KeyboardShortcuts.html ${REV} ${DOC_DIR}/topics/KeyboardShortcuts.adoc
  32. DEPENDS ${doc_depends}
  33. VERBATIM)
  34. add_custom_target(docs ALL DEPENDS KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html)
  35. install(FILES
  36. ${OUT_DIR}/KeePassXC_GettingStarted.html
  37. ${OUT_DIR}/KeePassXC_UserGuide.html
  38. ${OUT_DIR}/KeePassXC_KeyboardShortcuts.html
  39. DESTINATION ${DATA_INSTALL_DIR}/docs)
  40. # Build Man Pages on Linux and macOS
  41. if(UNIX)
  42. add_custom_command(OUTPUT keepassxc.1 keepassxc-cli.1
  43. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc.1.adoc
  44. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ./man/keepassxc-cli.1.adoc
  45. DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc ${DOC_DIR}/man/keepassxc-cli.1.adoc
  46. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  47. VERBATIM)
  48. add_custom_target(manpages ALL DEPENDS keepassxc.1 keepassxc-cli.1)
  49. install(FILES
  50. ${OUT_DIR}/keepassxc.1
  51. ${OUT_DIR}/keepassxc-cli.1
  52. DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
  53. endif()