CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # SPDX-License-Identifier: curl
  22. #
  23. ###########################################################################
  24. # Load man_MANS from shared file
  25. transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  26. include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  27. function(add_manual_pages _listname)
  28. foreach(_file IN LISTS ${_listname})
  29. if(_file STREQUAL "libcurl-symbols.3")
  30. # Special case, an auto-generated file.
  31. set(_srcfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  32. else()
  33. set(_srcfile "${CMAKE_CURRENT_SOURCE_DIR}/${_file}")
  34. endif()
  35. string(REPLACE ".3" ".html" _htmlfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  36. add_custom_command(OUTPUT "${_htmlfile}"
  37. COMMAND roffit "--mandir=${CMAKE_CURRENT_SOURCE_DIR}" "${_srcfile}" > "${_htmlfile}"
  38. DEPENDS "${_srcfile}"
  39. VERBATIM
  40. )
  41. string(REPLACE ".3" ".pdf" _pdffile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  42. string(REPLACE ".3" ".ps" _psfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  43. # XXX any reason why groff -Tpdf (for gropdf) is not used?
  44. add_custom_command(OUTPUT "${_pdffile}"
  45. COMMAND groff -Tps -man "${_srcfile}" > "${_psfile}"
  46. COMMAND ps2pdf "${_psfile}" "${_pdffile}"
  47. COMMAND "${CMAKE_COMMAND}" -E remove "${_psfile}"
  48. DEPENDS "${_srcfile}"
  49. #BYPRODUCTS "${_psfile}"
  50. VERBATIM
  51. )
  52. # "BYPRODUCTS" for add_custom_command requires CMake 3.2. For now hope that
  53. # the temporary files are removed (i.e. the command is not interrupted).
  54. endforeach()
  55. endfunction()
  56. add_custom_command(OUTPUT libcurl-symbols.3
  57. COMMAND
  58. "${PERL_EXECUTABLE}"
  59. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl" <
  60. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions" > libcurl-symbols.3
  61. DEPENDS
  62. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions"
  63. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl"
  64. VERBATIM
  65. )
  66. add_manual_pages(man_MANS)
  67. string(REPLACE ".3" ".html" HTMLPAGES "${man_MANS}")
  68. string(REPLACE ".3" ".pdf" PDFPAGES "${man_MANS}")
  69. add_custom_target(html DEPENDS ${HTMLPAGES})
  70. add_custom_target(pdf DEPENDS ${PDFPAGES})
  71. add_subdirectory(opts)