CMakeLists.txt 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. # Get 'man_MANS' variable
  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. # Maximum number of files per command to stay within shell/OS limits
  29. if(CMAKE_HOST_UNIX)
  30. set(_files_per_batch 10000)
  31. else() # e.g. Windows with cmd.exe and other obsolete/unidentified shells
  32. set(_files_per_batch 200)
  33. endif()
  34. set(_file_count 0)
  35. unset(_rofffiles)
  36. unset(_mdfiles)
  37. set(_eol "_EOL_")
  38. foreach(_file IN LISTS ${_listname} _eol)
  39. math(EXPR _file_count "${_file_count} + 1")
  40. if(_file_count GREATER_EQUAL _files_per_batch OR _file STREQUAL "_EOL_")
  41. add_custom_command(OUTPUT ${_rofffiles}
  42. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  43. COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/cd2nroff" -k -d "${CMAKE_CURRENT_BINARY_DIR}" ${_mdfiles}
  44. DEPENDS ${_mdfiles}
  45. VERBATIM
  46. )
  47. set(_file_count 0)
  48. unset(_rofffiles)
  49. unset(_mdfiles)
  50. endif()
  51. list(APPEND _rofffiles "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  52. if(_file STREQUAL "libcurl-symbols.3")
  53. # Special case, an auto-generated file.
  54. string(REPLACE ".3" ".md" _mdfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
  55. else()
  56. string(REPLACE ".3" ".md" _mdfile "${_file}")
  57. endif()
  58. list(APPEND _mdfiles "${_mdfile}")
  59. endforeach()
  60. endfunction()
  61. add_custom_command(OUTPUT "libcurl-symbols.md"
  62. COMMAND
  63. "${PERL_EXECUTABLE}"
  64. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl" <
  65. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions" > "libcurl-symbols.md"
  66. DEPENDS
  67. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions"
  68. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl"
  69. VERBATIM
  70. )
  71. add_manual_pages(man_MANS)
  72. add_custom_target(curl-man ALL DEPENDS ${man_MANS})
  73. if(NOT CURL_DISABLE_INSTALL)
  74. unset(_src)
  75. foreach(_f IN LISTS man_MANS)
  76. list(APPEND _src "${CMAKE_CURRENT_BINARY_DIR}/${_f}")
  77. endforeach()
  78. install(FILES ${_src} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
  79. endif()
  80. add_subdirectory(opts)