CMakeLists.txt 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. file(GLOB html_depends ${DOC_DIR}/topics/* ${DOC_DIR}/styles/* ${DOC_DIR}/images/*)
  25. add_custom_command(OUTPUT KeePassXC_GettingStarted.html
  26. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_GettingStarted.html ${REV} ${DOC_DIR}/GettingStarted.adoc
  27. DEPENDS ${html_depends} ${DOC_DIR}/GettingStarted.adoc
  28. VERBATIM)
  29. add_custom_command(OUTPUT KeePassXC_UserGuide.html
  30. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_UserGuide.html ${REV} ${DOC_DIR}/UserGuide.adoc
  31. DEPENDS ${html_depends} ${DOC_DIR}/UserGuide.adoc
  32. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  33. VERBATIM)
  34. file(GLOB styles_depends ${DOC_DIR}/styles/*)
  35. add_custom_command(OUTPUT KeePassXC_KeyboardShortcuts.html
  36. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -o KeePassXC_KeyboardShortcuts.html ${REV} ${DOC_DIR}/topics/KeyboardShortcuts.adoc
  37. DEPENDS ${DOC_DIR}/topics/KeyboardShortcuts.adoc ${styles_depends}
  38. VERBATIM)
  39. add_custom_target(docs ALL DEPENDS KeePassXC_GettingStarted.html KeePassXC_UserGuide.html KeePassXC_KeyboardShortcuts.html)
  40. install(FILES
  41. ${OUT_DIR}/KeePassXC_GettingStarted.html
  42. ${OUT_DIR}/KeePassXC_UserGuide.html
  43. ${OUT_DIR}/KeePassXC_KeyboardShortcuts.html
  44. DESTINATION ${DATA_INSTALL_DIR}/docs)
  45. # Build Man Pages on Linux and macOS
  46. if(UNIX)
  47. add_custom_command(OUTPUT keepassxc.1
  48. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc.1.adoc
  49. DEPENDS ${DOC_DIR}/man/keepassxc.1.adoc
  50. VERBATIM)
  51. add_custom_command(OUTPUT keepassxc-cli.1
  52. COMMAND ${ASCIIDOCTOR_EXE} -D ${OUT_DIR} -b manpage ${REV} ${DOC_DIR}/man/keepassxc-cli.1.adoc
  53. DEPENDS ${DOC_DIR}/man/keepassxc-cli.1.adoc
  54. VERBATIM)
  55. add_custom_target(manpages ALL DEPENDS keepassxc.1 keepassxc-cli.1)
  56. install(FILES
  57. ${OUT_DIR}/keepassxc.1
  58. ${OUT_DIR}/keepassxc-cli.1
  59. DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
  60. endif()