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

CMakeLists.txt 11 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
  1. #
  2. # Copyright (c) 1991-2021 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
  3. # See LICENSE.TXT file for copying and redistribution conditions.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; version 3 or any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Lesser General Public License for more details.
  13. #
  14. # Contact info: www.generic-mapping-tools.org
  15. #-------------------------------------------------------------------------------
  16. #
  17. # To configure the cmake process:
  18. #
  19. # 1. copy the configuration template 'cmake/ConfigUserTemplate.cmake'
  20. # to 'cmake/ConfigUser.cmake', then edit 'cmake/ConfigUser.cmake' to
  21. # override basic default settings on a per-user basis;
  22. # 2. copy the configuration template 'cmake/ConfigUserAdvancedTemplate.cmake'
  23. # to 'cmake/ConfigUserAdvanced.cmake', then edit 'cmake/ConfigUserAdvanced.cmake' to
  24. # override advanced default settings on a per-user basis.
  25. #
  26. # To build out-of-source do (example):
  27. #
  28. # mkdir build
  29. # cd build
  30. # cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
  31. #
  32. # CMAKE_BUILD_TYPE can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
  33. #
  34. # Make sure the user doesn't play dirty with symlinks
  35. get_filename_component (srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
  36. get_filename_component (bindir "${CMAKE_BINARY_DIR}" REALPATH)
  37. # Disallow in-source builds
  38. if (${srcdir} STREQUAL ${bindir})
  39. message(FATAL_ERROR "In-source builds are not allowed. "
  40. "Please create a directory and run cmake from there, passing the path "
  41. "to this source directory as the last argument. This process created "
  42. "the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}. "
  43. "Please remove them.")
  44. endif (${srcdir} STREQUAL ${bindir})
  45. # Define minimum CMake version required
  46. cmake_minimum_required (VERSION 2.8.12)
  47. message ("CMake version: ${CMAKE_VERSION}")
  48. # Use NEW behavior with newer CMake releases
  49. foreach (p
  50. CMP0025 # CMake 3.0: Compiler id for Apple Clang is now AppleClang
  51. CMP0026 # CMake 3.0: Disallow use of the LOCATION target property
  52. CMP0058 # CMake 3.3: Ninja requires custom command byproducts to be explicit
  53. CMP0074 # CMake 3.12: find_package uses PackageName_ROOT variables
  54. CMP0115 # CMake 3.20: Source file extensions must be explicit.
  55. )
  56. if (POLICY ${p})
  57. cmake_policy (SET ${p} NEW)
  58. endif()
  59. endforeach()
  60. # Define project name and language
  61. project (GMT C)
  62. # Where to find our CMake modules (this variable is visible in subdirectories).
  63. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/"
  64. CACHE INTERNAL "Location of our custom CMake modules." FORCE)
  65. # Find UNIX commands
  66. include (FindUnixCommands)
  67. find_package (Git)
  68. # Include configuration options (default options and options overridden by user).
  69. include (ConfigCMake)
  70. # Global test target
  71. add_custom_target (check
  72. COMMAND ${CMAKE_CTEST_COMMAND}
  73. --output-on-failure --force-new-ctest-process -j${N_TEST_JOBS})
  74. # Find test dependencies
  75. find_program (GRAPHICSMAGICK gm)
  76. if (DO_EXAMPLES OR DO_TESTS AND NOT GRAPHICSMAGICK)
  77. message (FATAL_ERROR "Cannot proceed without GraphicsMagick. "
  78. "Need to either install GraphicsMagick or disable tests.")
  79. endif (DO_EXAMPLES OR DO_TESTS AND NOT GRAPHICSMAGICK)
  80. # Find latex and dvips for LaTeX integration
  81. find_program (LATEX latex)
  82. find_program (DVIPS dvips)
  83. # Add subdirectories
  84. add_subdirectory (src)
  85. add_subdirectory (share) # share must be processed *after* src (GSHHG_PATH)
  86. add_subdirectory (doc) # doc must be processed *after* src
  87. if (EXISTS ${GMT_SOURCE_DIR}/test/)
  88. add_subdirectory (test)
  89. endif (EXISTS ${GMT_SOURCE_DIR}/test/)
  90. add_subdirectory (cmake/dist) # make distribution bundles (always last)
  91. # Source release target
  92. if (GIT_FOUND AND HAVE_GIT_VERSION)
  93. # Export git working tree, and remove some directories and files
  94. # so that they are not included in the final release tarball
  95. add_custom_target (git_export_release
  96. COMMAND ${GIT_EXECUTABLE} -C ${GMT_SOURCE_DIR} checkout-index -a -f --prefix=${GMT_RELEASE_PREFIX}/
  97. # cmake<3.15 can't remove multiple directories using cmake -E remove_directory
  98. COMMAND ${CMAKE_COMMAND} -E remove_directory ${GMT_RELEASE_PREFIX}/.git
  99. COMMAND ${CMAKE_COMMAND} -E remove_directory ${GMT_RELEASE_PREFIX}/.github
  100. COMMAND ${CMAKE_COMMAND} -E remove_directory ${GMT_RELEASE_PREFIX}/admin
  101. COMMAND ${CMAKE_COMMAND} -E remove_directory ${GMT_RELEASE_PREFIX}/ci
  102. COMMAND ${CMAKE_COMMAND} -E remove_directory ${GMT_RELEASE_PREFIX}/test
  103. COMMAND ${CMAKE_COMMAND} -E remove ${GMT_RELEASE_PREFIX}/.gitignore
  104. COMMAND ${CMAKE_COMMAND} -E remove ${GMT_RELEASE_PREFIX}/package.json
  105. COMMAND ${CMAKE_COMMAND} -E remove ${GMT_RELEASE_PREFIX}/vercel.json
  106. )
  107. add_depend_to_target (gmt_release git_export_release)
  108. find_program (GNUTAR NAMES gnutar gtar tar)
  109. find_program (XZ NAMES xz)
  110. if (GNUTAR AND GZIP AND XZ)
  111. # Targets for creating tarballs
  112. get_filename_component (_release_dirname "${GMT_RELEASE_PREFIX}" NAME)
  113. add_custom_command (OUTPUT ${_release_dirname}-src.tar
  114. COMMAND ${GNUTAR} -c --owner 0 --group 0 --mode a=rX,u=rwX --force-local
  115. -f ${GMT_BINARY_DIR}/${_release_dirname}-src.tar ${_release_dirname}
  116. DEPENDS ${GMT_RELEASE_PREFIX}
  117. WORKING_DIRECTORY ${GMT_RELEASE_PREFIX}/..
  118. VERBATIM)
  119. add_custom_command (OUTPUT ${_release_dirname}-src.tar.gz
  120. COMMAND ${GZIP} -9 --keep --force ${GMT_BINARY_DIR}/${_release_dirname}-src.tar
  121. DEPENDS ${GMT_RELEASE_PREFIX} ${_release_dirname}-src.tar
  122. WORKING_DIRECTORY ${GMT_RELEASE_PREFIX}/..
  123. VERBATIM)
  124. add_custom_command (OUTPUT ${_release_dirname}-src.tar.xz
  125. COMMAND ${XZ} -9 -T 0 --keep --force ${GMT_BINARY_DIR}/${_release_dirname}-src.tar
  126. DEPENDS ${GMT_RELEASE_PREFIX} ${_release_dirname}-src.tar
  127. WORKING_DIRECTORY ${GMT_RELEASE_PREFIX}/..
  128. VERBATIM)
  129. add_custom_target (gmt_release_tar
  130. DEPENDS ${GMT_RELEASE_PREFIX}
  131. ${_release_dirname}-src.tar.gz ${_release_dirname}-src.tar.xz)
  132. endif (GNUTAR AND GZIP AND XZ)
  133. endif (GIT_FOUND AND HAVE_GIT_VERSION)
  134. # Get suffix for libraries
  135. set (_lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
  136. # Get name of GMT core library
  137. get_target_property (_name gmtlib RUNTIME_OUTPUT_NAME)
  138. get_target_property (_prefix gmtlib PREFIX)
  139. set (GMT_CORE_LIB_NAME ${_prefix}${_name}${_lib_suffix})
  140. # Get name of PSL library
  141. get_target_property (_name pslib RUNTIME_OUTPUT_NAME)
  142. get_target_property (_prefix pslib PREFIX)
  143. set (PSL_LIB_NAME ${_prefix}${_name}${_lib_suffix})
  144. # Get name of shared supplemental library
  145. if (BUILD_SUPPLEMENTS)
  146. get_target_property (_name ${GMT_SUPPL_LIB_NAME} RUNTIME_OUTPUT_NAME)
  147. get_target_property (_prefix ${GMT_SUPPL_LIB_NAME} PREFIX)
  148. set (GMT_SUPPL_LIBRARY ${_prefix}${_name}${CMAKE_SHARED_MODULE_SUFFIX})
  149. set (SUPPL "yes [${GMT_SUPPL_LIBRARY}]")
  150. else (BUILD_SUPPLEMENTS)
  151. set (SUPPL "no")
  152. endif (BUILD_SUPPLEMENTS)
  153. if (BUILD_DEVELOPER)
  154. set (DEVEL "yes")
  155. else (BUILD_DEVELOPER)
  156. set (DEVEL "no")
  157. endif (BUILD_DEVELOPER)
  158. if (SUPPL_EXTRA_DIRS)
  159. set (PROTO ${SUPPL_EXTRA_DIRS})
  160. else (SUPPL_EXTRA_DIRS)
  161. set (PROTO "none")
  162. endif (SUPPL_EXTRA_DIRS)
  163. if (GMT_INSTALL_MODULE_LINKS)
  164. set (LINKS "yes")
  165. else (GMT_INSTALL_MODULE_LINKS)
  166. set (LINKS "no")
  167. endif (GMT_INSTALL_MODULE_LINKS)
  168. # Configure header file to pass some of the CMake settings to the source code
  169. configure_file (src/config.h.in src/config.h)
  170. if (DCW_PATH)
  171. set (GMT_CONFIG_DCW_MESSAGE "${DCW_PATH} (${DCW_VERSION})")
  172. else (DCW_PATH)
  173. set (GMT_CONFIG_DCW_MESSAGE "${DCW_PATH} (GMT will download on demand)")
  174. endif (DCW_PATH)
  175. if (GSHHG_PATH)
  176. set (GMT_CONFIG_GSHHG_MESSAGE "${GSHHG_PATH} (${GSHHG_VERSION})")
  177. else (GSHHG_PATH)
  178. set (GMT_CONFIG_GSHHG_MESSAGE "${GSHHG_PATH} (GMT will download on demand)")
  179. endif (GSHHG_PATH)
  180. # Configuration done
  181. message(
  182. "*\n"
  183. "* GMT Version: : ${GMT_PACKAGE_VERSION_WITH_GIT_REVISION}\n"
  184. "*\n"
  185. "* Options:\n"
  186. "* Found GSHHG database : ${GMT_CONFIG_GSHHG_MESSAGE}\n"
  187. "* Found DCW-GMT database : ${GMT_CONFIG_DCW_MESSAGE}\n"
  188. "* Found GMT data server : ${GMT_DATA_SERVER}\n"
  189. "* NetCDF library : ${NETCDF_LIBRARY}\n"
  190. "* NetCDF include dir : ${NETCDF_INCLUDE_DIR}\n"
  191. "* Curl library : ${CURL_LIBRARY}\n"
  192. "* Curl include dir : ${CURL_INCLUDE_DIR}\n"
  193. "* GDAL library : ${GDAL_LIBRARY}\n"
  194. "* GDAL include dir : ${GDAL_INCLUDE_DIR}\n"
  195. "* GEOS library : ${GEOS_LIBRARY}\n"
  196. "* GEOS include dir : ${GEOS_INCLUDE_DIR}\n"
  197. "* FFTW library : ${FFTW3F_LIBRARY}\n"
  198. "* FFTW threads library : ${FFTW3F_THREADS_LIBRARY}\n"
  199. "* FFTW include dir : ${FFTW3_INCLUDE_DIR}\n"
  200. "* Accelerate Framework : ${ACCELERATE_FRAMEWORK}\n"
  201. "* Regex support : ${GMT_CONFIG_REGEX_MESSAGE}\n"
  202. "* ZLIB library : ${ZLIB_LIBRARY}\n"
  203. "* ZLIB include dir : ${ZLIB_INCLUDE_DIR}\n"
  204. "* LAPACK library : ${GMT_CONFIG_LAPACK_MESSAGE}\n"
  205. "* BLAS library : ${GMT_CONFIG_BLAS_MESSAGE}\n"
  206. "* License restriction : ${LICENSE_RESTRICTED}\n"
  207. "* Triangulation method : ${GMT_TRIANGULATE}\n"
  208. "* OpenMP support : ${GMT_CONFIG_OPENMP_MESSAGE}\n"
  209. "* GLIB GTHREAD support : ${GMT_CONFIG_GTHREAD_MESSAGE}\n"
  210. "* Build generator : ${CMAKE_GENERATOR}\n"
  211. "* Build GMT core : always [${GMT_CORE_LIB_NAME}]\n"
  212. "* Build PSL library : always [${PSL_LIB_NAME}]\n"
  213. "* Build GMT supplements : ${SUPPL}\n"
  214. "* Build GMT for developers : ${DEVEL}\n"
  215. "* Build proto supplements : ${PROTO}\n"
  216. "* Build module links : ${LINKS}\n"
  217. "* Found Ghostscript (gs) : ${GMT_CONFIG_GS_MESSAGE}\n"
  218. "* Found GraphicsMagick (gm) : ${GMT_CONFIG_GM_MESSAGE}\n"
  219. "* Found ffmpeg : ${GMT_CONFIG_FFMPEG_MESSAGE}\n"
  220. "* Found open : ${GMT_CONFIG_OPEN_MESSAGE}\n"
  221. "* Found ogr2ogr : ${GMT_CONFIG_OGR2OGR_MESSAGE}\n"
  222. "* Found gdal_translate : ${GMT_CONFIG_GDAL_TRANSLATE_MESSAGE}\n"
  223. "*\n"
  224. "* Locations:\n"
  225. "* Installing GMT in : ${CMAKE_INSTALL_PREFIX}\n"
  226. "* GMT_DATADIR : ${CMAKE_INSTALL_PREFIX}/${GMT_DATADIR}\n"
  227. "* GMT_DOCDIR : ${CMAKE_INSTALL_PREFIX}/${GMT_DOCDIR}\n"
  228. "* GMT_MANDIR : ${CMAKE_INSTALL_PREFIX}/${GMT_MANDIR}")
  229. # For debugging: print all set variables
  230. #get_cmake_property(_variableNames VARIABLES)
  231. #foreach (_variableName ${_variableNames})
  232. # message(STATUS "${_variableName}=${${_variableName}}")
  233. #endforeach()
Tip!

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

Comments

Loading...