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