UseAsciidoc.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # - macro_asciidoc2man(inputfile outputfile)
  2. #
  3. # Create a manpage with asciidoc.
  4. # Example: macro_asciidoc2man(foo.txt foo.1)
  5. #
  6. # Copyright (c) 2006, Andreas Schneider, <asn@cryptomilk.org>
  7. #
  8. # Redistribution and use is allowed according to the terms of the BSD license.
  9. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  10. include(MacroCopyFile)
  11. macro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_output)
  12. find_program(A2X
  13. NAMES
  14. a2x
  15. )
  16. #message("+++ A2X: ${A2X}")
  17. if (A2X)
  18. #message("+++ ${A2X} --doctype=manpage --format=manpage --destination-dir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input}")
  19. macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_a2m_input} ${CMAKE_CURRENT_BINARY_DIR}/${_a2m_input})
  20. execute_process(
  21. COMMAND
  22. ${A2X} --doctype=manpage --format=manpage ${_a2m_input}
  23. WORKING_DIRECTORY
  24. ${CMAKE_CURRENT_BINARY_DIR}
  25. RESULT_VARIABLE
  26. A2M_MAN_GENERATED
  27. ERROR_QUIET
  28. )
  29. #message("+++ A2M_MAN_GENERATED: ${A2M_MAN_GENERATED}")
  30. if (A2M_MAN_GENERATED EQUAL 0)
  31. find_file(A2M_MAN_FILE
  32. NAME
  33. ${_a2m_output}
  34. PATHS
  35. ${CMAKE_CURRENT_BINARY_DIR}
  36. NO_DEFAULT_PATH
  37. )
  38. if (A2M_MAN_FILE)
  39. get_filename_component(A2M_MAN_CATEGORY ${A2M_MAN_FILE} EXT)
  40. string(SUBSTRING ${A2M_MAN_CATEGORY} 1 1 A2M_MAN_CATEGORY)
  41. install(
  42. FILES
  43. ${A2M_MAN_FILE}
  44. DESTINATION
  45. ${MAN_INSTALL_DIR}/man${A2M_MAN_CATEGORY}
  46. )
  47. endif (A2M_MAN_FILE)
  48. endif (A2M_MAN_GENERATED EQUAL 0)
  49. endif (A2X)
  50. endmacro(MACRO_ASCIIDOC2MAN _a2m_input _a2m_file)