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