Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

GmtManpages.cmake 6.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
  1. #
  2. # $Id$
  3. #
  4. # - Generates manpages from txt-files and creates installation targets
  5. # GMT_CREATE_MANPAGES ("${MAN_FILES}" [DEPENDS [DEPENDS2] ...]])
  6. #
  7. # MAN_FILES - list of manpages, e.g., user.1 system.2 special.4 formats.5
  8. # DEPENDS - list of dependencies
  9. #
  10. # Typical use:
  11. # set (MAN_FILES user.1 system.2 special.4 formats.5)
  12. # GMT_CREATE_MANPAGES ("${MAN_FILES}")
  13. #
  14. # Copyright (c) 1991-2015 by P. Wessel, W. H. F. Smith, R. Scharroo, J. Luis and F. Wobbe
  15. # See LICENSE.TXT file for copying and redistribution conditions.
  16. #
  17. # This program is free software; you can redistribute it and/or modify
  18. # it under the terms of the GNU Lesser General Public License as published by
  19. # the Free Software Foundation; version 3 or any later version.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU Lesser General Public License for more details.
  25. #
  26. # Contact info: gmt.soest.hawaii.edu
  27. #-------------------------------------------------------------------------------
  28. if(NOT DEFINED _GMT_MANPAGES_CMAKE_)
  29. set(_GMT_MANPAGES_CMAKE_ "DEFINED")
  30. # usefull macros
  31. include (GmtHelperMacros)
  32. # Find groff front-end
  33. find_program (GROFF groff)
  34. # Only create manpages if HAVE_TRADITIONAL_CPP is set and
  35. # GMT_INSTALL_EXTERNAL_MAN is OFF. Otherwise install precompiled manpages
  36. # from man_release.
  37. if (EXISTS ${GMT_INSTALL_EXTERNAL_MAN})
  38. # Install manpages from external location
  39. set (_HAVE_EXTERNAL_MAN TRUE)
  40. install (DIRECTORY ${GMT_INSTALL_EXTERNAL_MAN}/
  41. DESTINATION ${GMT_MANDIR}
  42. COMPONENT Runtime
  43. USE_SOURCE_PERMISSIONS)
  44. elseif (EXISTS ${GMT_INSTALL_EXTERNAL_MAN})
  45. # No external manpages available
  46. set (_HAVE_EXTERNAL_MAN FALSE)
  47. endif (EXISTS ${GMT_INSTALL_EXTERNAL_MAN})
  48. macro (GMT_CREATE_MANPAGES MAN_FILES)
  49. if (HAVE_TRADITIONAL_CPP AND NOT _HAVE_EXTERNAL_MAN)
  50. # parse arguments
  51. set (_arg_is_man_file TRUE)
  52. set (_man_files ${MAN_FILES})
  53. set (_depends ${GMT_GEN_MAN_HEADERS})
  54. foreach (_arg ${ARGN})
  55. if (_arg_is_man_file AND _arg STREQUAL "DEPENDS")
  56. set (_arg_is_man_file FALSE)
  57. endif (_arg_is_man_file AND _arg STREQUAL "DEPENDS")
  58. if (_arg_is_man_file)
  59. list (APPEND _man_files ${_arg})
  60. else (_arg_is_man_file)
  61. list (APPEND _depends ${_arg})
  62. endif (_arg_is_man_file)
  63. endforeach (_arg ${ARGN})
  64. # create tag from current dirname
  65. tag_from_current_source_dir (_tag "_")
  66. # clear lists
  67. set (_install_sections)
  68. set (_target_depends)
  69. set (_manfiles_html)
  70. # set preprocessor flags
  71. if (MSVC)
  72. set (_cpp_flags /EP /nologo)
  73. else (MSVC)
  74. # GNU C
  75. set (_cpp_flags -E -w -P -nostdinc -traditional-cpp - <)
  76. endif (MSVC)
  77. foreach (_manfile ${_man_files})
  78. # strip section number
  79. string (REGEX MATCH "[1-8]$" _man_section ${_manfile})
  80. if (NOT _man_section)
  81. # only manfile.[1-8] supported
  82. message (FATAL_ERROR "cannot generate ${_man_unsupported}")
  83. endif (NOT _man_section)
  84. list (APPEND _install_sections ${_man_section})
  85. # generator
  86. string (REGEX REPLACE "\\.[1-8]$" ".txt" _man_src ${_manfile})
  87. # uncompressed manpage
  88. add_custom_command (
  89. OUTPUT ${_manfile}
  90. COMMAND ${CMAKE_C_COMPILER}
  91. -I${GMT_SOURCE_DIR}/src
  92. -I${GMT_BINARY_DIR}/src
  93. -I${CMAKE_CURRENT_SOURCE_DIR}
  94. ${_cpp_flags}
  95. ${CMAKE_CURRENT_SOURCE_DIR}/${_man_src}
  96. > ${_manfile}
  97. DEPENDS ${_man_src} ${_depends}
  98. VERBATIM)
  99. # compress manpage
  100. if(GZIP)
  101. add_custom_command (
  102. OUTPUT ${_manfile}.gz
  103. COMMAND ${GZIP} -9 -c ${_manfile} > ${_manfile}.gz
  104. DEPENDS ${_manfile}
  105. VERBATIM)
  106. set (_gz ".gz")
  107. endif(GZIP)
  108. # append full path + make list for each man section
  109. list (APPEND _manfilepaths_${_man_section}
  110. "${CMAKE_CURRENT_BINARY_DIR}/${_manfile}${_gz}")
  111. list (APPEND _target_depends "${_manfile}${_gz}")
  112. if (GROFF)
  113. # ps manpages
  114. add_custom_command (
  115. OUTPUT ${_manfile}.ps
  116. COMMAND ${GROFF} -mandoc -T ps
  117. ${_manfile} > ${_manfile}.ps
  118. DEPENDS ${_manfile}
  119. VERBATIM)
  120. # append to list of ps manfiles
  121. if (_tag)
  122. # supplement manpage
  123. list (APPEND _manfiles_suppl_ps
  124. "${CMAKE_CURRENT_BINARY_DIR}/${_manfile}.ps")
  125. else (_tag)
  126. # gmt manpage
  127. list (APPEND _manfiles_ps
  128. "${CMAKE_CURRENT_BINARY_DIR}/${_manfile}.ps")
  129. endif (_tag)
  130. list (APPEND _target_depends ${_manfile}.ps)
  131. endif (GROFF)
  132. # html manpages
  133. add_custom_command (
  134. OUTPUT ${_manfile}.html
  135. COMMAND ${GMT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/src/rman
  136. -S -f HTML
  137. < ${_manfile} > ${_manfile}.html
  138. DEPENDS ${_manfile} rman
  139. VERBATIM)
  140. # install target for realease documentation
  141. if (SVN AND HAVE_SVN_VERSION)
  142. add_custom_target (gmt_manfiles_html_release_${_manfile}
  143. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  144. ${_manfile}.html
  145. ${GMT_RELEASE_PREFIX}/doc_release/html/${_manfile}.html
  146. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  147. ${_manfile}${_gz}
  148. ${GMT_RELEASE_PREFIX}/man_release/man${_man_section}/${_manfile}${_gz}
  149. DEPENDS ${_manfile}${_gz} ${_manfile}.html)
  150. add_depend_to_target (gmt_release
  151. gmt_manfiles_html_release_${_manfile})
  152. endif (SVN AND HAVE_SVN_VERSION)
  153. # append to list of html manfiles
  154. list (APPEND _manfiles_html
  155. "${CMAKE_CURRENT_BINARY_DIR}/${_manfile}.html")
  156. list (APPEND _target_depends ${_manfile}.html)
  157. endforeach (_manfile)
  158. # manpage target
  159. add_custom_target (manpages${_tag} DEPENDS ${_target_depends})
  160. add_depend_to_target (manpages_all manpages${_tag})
  161. # install manpages
  162. list (SORT _install_sections)
  163. list (REMOVE_DUPLICATES _install_sections)
  164. foreach (_man_section ${_install_sections})
  165. install (FILES ${_manfilepaths_${_man_section}}
  166. DESTINATION ${GMT_MANDIR}/man${_man_section}
  167. COMPONENT Runtime
  168. OPTIONAL)
  169. endforeach (_man_section ${_install_sections})
  170. # install html manpages
  171. install (FILES ${_manfiles_html}
  172. DESTINATION ${GMT_DOCDIR}/html
  173. COMPONENT Documentation
  174. OPTIONAL)
  175. # remember _manfiles_ps
  176. if (_tag)
  177. set(_manfiles_suppl_ps "${_manfiles_suppl_ps}" CACHE INTERNAL
  178. "Global list of supplement PS manpages")
  179. else (_tag)
  180. set(_manfiles_ps "${_manfiles_ps}" CACHE INTERNAL
  181. "Global list of PS manpages")
  182. endif (_tag)
  183. endif (HAVE_TRADITIONAL_CPP AND NOT _HAVE_EXTERNAL_MAN)
  184. endmacro (GMT_CREATE_MANPAGES MAN_FILES)
  185. endif(NOT DEFINED _GMT_MANPAGES_CMAKE_)
  186. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...