2
0

CMakeLists.txt 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. curl_transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  26. include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
  27. function(curl_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. set(_rofffiles "")
  36. set(_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. set(_rofffiles "")
  49. set(_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. unset(_rofffiles)
  61. unset(_mdfiles)
  62. endfunction()
  63. add_custom_command(OUTPUT "libcurl-symbols.md"
  64. COMMAND
  65. "${PERL_EXECUTABLE}"
  66. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl" <
  67. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions" > "libcurl-symbols.md"
  68. DEPENDS
  69. "${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions"
  70. "${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl"
  71. VERBATIM
  72. )
  73. curl_add_manual_pages(man_MANS)
  74. add_custom_target(curl-man ALL DEPENDS ${man_MANS})
  75. if(NOT CURL_DISABLE_INSTALL)
  76. set(_src "")
  77. foreach(_f IN LISTS man_MANS)
  78. list(APPEND _src "${CMAKE_CURRENT_BINARY_DIR}/${_f}")
  79. endforeach()
  80. install(FILES ${_src} DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
  81. unset(_src)
  82. endif()
  83. add_subdirectory(opts)