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

ConfigCMake.cmake 9.0 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
  1. #
  2. # $Id$
  3. #
  4. # Useful CMake variables.
  5. #
  6. # There are three configuration files:
  7. # 1) "ConfigDefault.cmake" - is version controlled and used to add new default
  8. # variables and set defaults for everyone.
  9. # 2) "ConfigUser.cmake" in the source tree - is not version controlled
  10. # (currently listed in svn:ignore property) and used to override defaults on
  11. # a per-user basis.
  12. # 3) "ConfigUser.cmake" in the build tree - is used to override
  13. # "ConfigUser.cmake" in the source tree.
  14. #
  15. # NOTE: If you want to change CMake behaviour just for yourself then copy
  16. # "ConfigUserTemplate.cmake" to "ConfigUser.cmake" and then edit
  17. # "ConfigUser.cmake" (not "ConfigDefault.cmake" or "ConfigUserTemplate.cmake").
  18. #
  19. include ("${CMAKE_SOURCE_DIR}/cmake/ConfigDefault.cmake")
  20. # If "ConfigUser.cmake" doesn't exist then create one for convenience.
  21. if (EXISTS "${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake")
  22. include ("${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake")
  23. endif (EXISTS "${CMAKE_SOURCE_DIR}/cmake/ConfigUser.cmake")
  24. # If you've got a 'ConfigUser.cmake' in the build tree then that overrides the
  25. # one in the source tree.
  26. if (EXISTS "${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake")
  27. include ("${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake")
  28. endif (EXISTS "${CMAKE_BINARY_DIR}/cmake/ConfigUser.cmake")
  29. ###########################################################
  30. # Do any needed processing of the configuration variables #
  31. ###########################################################
  32. # Build type
  33. if (NOT CMAKE_BUILD_TYPE)
  34. set (CMAKE_BUILD_TYPE Release)
  35. endif (NOT CMAKE_BUILD_TYPE)
  36. # Here we change it to add the SVN revision number for non-public releases - see Package.cmake for
  37. # why this has to be done here.
  38. set (GMT_PACKAGE_VERSION_WITH_SVN_REVISION ${GMT_PACKAGE_VERSION})
  39. # Add the Subversion version number to the package filename if this is a non-public release.
  40. # A non-public release has an empty 'GMT_SOURCE_CODE_CONTROL_VERSION_STRING' variable in 'ConfigDefault.cmake'.
  41. set (HAVE_SVN_VERSION)
  42. if (NOT GMT_SOURCE_CODE_CONTROL_VERSION_STRING)
  43. # Get the location, inside the staging area location, to copy the application bundle to.
  44. execute_process (
  45. COMMAND svnversion ${GMT_SOURCE_DIR}
  46. RESULT_VARIABLE SVN_VERSION_RESULT
  47. OUTPUT_VARIABLE SVN_VERSION_OUTPUT
  48. OUTPUT_STRIP_TRAILING_WHITESPACE)
  49. if (SVN_VERSION_RESULT)
  50. message (STATUS "Unable to determine svn version number for non-public release - ignoring.")
  51. else (SVN_VERSION_RESULT)
  52. if (SVN_VERSION_OUTPUT MATCHES "Unversioned")
  53. message (STATUS "Unversioned source tree, non-public release.")
  54. else (SVN_VERSION_OUTPUT MATCHES "Unversioned")
  55. # The 'svnversion' command can output a range of revisions with a colon
  56. # separator - but this causes problems with filenames so we'll remove the
  57. # colon and the end revision after it.
  58. string (REGEX REPLACE ":.*$" "" SVN_VERSION ${SVN_VERSION_OUTPUT})
  59. if (NOT SVN_VERSION STREQUAL exported)
  60. # Set the updated package version.
  61. set (GMT_PACKAGE_VERSION_WITH_SVN_REVISION "${GMT_PACKAGE_VERSION}_r${SVN_VERSION}")
  62. set (HAVE_SVN_VERSION TRUE)
  63. endif (NOT SVN_VERSION STREQUAL exported)
  64. endif (SVN_VERSION_OUTPUT MATCHES "Unversioned")
  65. endif (SVN_VERSION_RESULT)
  66. endif (NOT GMT_SOURCE_CODE_CONTROL_VERSION_STRING)
  67. # The current GMT version.
  68. set (GMT_VERSION_STRING "${GMT_PACKAGE_NAME} ${GMT_PACKAGE_VERSION_WITH_SVN_REVISION}")
  69. set (GMT_LONG_VERSION_STRING "${GMT_PACKAGE_NAME} - ${GMT_PACKAGE_DESCRIPTION_SUMMARY}, Version ${GMT_PACKAGE_VERSION_WITH_SVN_REVISION}")
  70. # Get date
  71. try_run (_exit_today _compiled_today
  72. ${CMAKE_BINARY_DIR}/CMakeTmp
  73. ${CMAKE_MODULE_PATH}/today.c
  74. CMAKE_FLAGS
  75. RUN_OUTPUT_VARIABLE _today)
  76. if (NOT _compiled_today OR _exit_today EQUAL -1)
  77. message (WARNING "Date not implemented, please file a bug report.")
  78. set(_today "1313;13;13;Undecember")
  79. endif (NOT _compiled_today OR _exit_today EQUAL -1)
  80. list(GET _today 0 YEAR)
  81. list(GET _today 1 MONTH)
  82. list(GET _today 2 DAY)
  83. list(GET _today 3 MONTHNAME)
  84. list(GET _today 0 1 2 DATE)
  85. string (REPLACE ";" "-" DATE "${DATE}")
  86. set (_today)
  87. # set package date
  88. if (NOT GMT_VERSION_YEAR)
  89. set (GMT_VERSION_YEAR ${YEAR})
  90. endif (NOT GMT_VERSION_YEAR)
  91. # apply license restrictions
  92. if (LICENSE_RESTRICTED) # on
  93. if (LICENSE_RESTRICTED STREQUAL GPL)
  94. # restrict to GPL
  95. elseif (LICENSE_RESTRICTED STREQUAL LGPL)
  96. # restrict to LGPL
  97. else (LICENSE_RESTRICTED STREQUAL GPL)
  98. # unknown license
  99. message (WARNING "unknown license: ${LICENSE_RESTRICTED}")
  100. endif (LICENSE_RESTRICTED STREQUAL GPL)
  101. # restrictions that apply to any of the above licenses
  102. else (LICENSE_RESTRICTED) # off
  103. # no restrictions at all
  104. endif (LICENSE_RESTRICTED)
  105. # reset list of extra license files
  106. set (GMT_EXTRA_LICENSE_FILES)
  107. # location of GNU license files
  108. set (COPYING_GPL ${GMT_SOURCE_DIR}/COPYINGv3)
  109. set (COPYING_LGPL ${GMT_SOURCE_DIR}/COPYING.LESSERv3)
  110. # GMT paths used in the code
  111. if (NOT GMT_DATADIR)
  112. # do not reset user setting
  113. if (GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  114. set (GMT_DATADIR "share")
  115. else(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  116. set (GMT_DATADIR
  117. "share/gmt${GMT_INSTALL_NAME_SUFFIX}")
  118. endif(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  119. endif (NOT GMT_DATADIR)
  120. # Install path GMT_DOCDIR
  121. if (NOT GMT_DOCDIR)
  122. # do not reset user setting
  123. if (GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  124. set (GMT_DOCDIR "${GMT_DATADIR}/doc")
  125. else(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  126. set (GMT_DOCDIR
  127. "share/doc/gmt${GMT_INSTALL_NAME_SUFFIX}")
  128. endif(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  129. endif (NOT GMT_DOCDIR)
  130. # Install path GMT_MANDIR
  131. if (NOT GMT_MANDIR)
  132. # do not reset user setting
  133. if (GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  134. set (GMT_MANDIR "${GMT_DATADIR}/man")
  135. else(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  136. set (GMT_MANDIR
  137. "${GMT_DOCDIR}/man")
  138. endif(GMT_INSTALL_TRADITIONAL_FOLDERNAMES)
  139. endif (NOT GMT_MANDIR)
  140. # Install path for GMT binaries, headers and libraries
  141. include (GNUInstallDirs) # defines CMAKE_INSTALL_LIBDIR (lib/lib64)
  142. if (NOT GMT_LIBDIR)
  143. set (GMT_LIBDIR ${CMAKE_INSTALL_LIBDIR})
  144. endif(NOT GMT_LIBDIR)
  145. if (NOT GMT_BINDIR)
  146. set (GMT_BINDIR bin)
  147. endif(NOT GMT_BINDIR)
  148. if (NOT GMT_INCLUDEDIR)
  149. set (GMT_INCLUDEDIR include/gmt${GMT_INSTALL_NAME_SUFFIX})
  150. endif(NOT GMT_INCLUDEDIR)
  151. # use, i.e. don't skip the full RPATH for the build tree
  152. set (CMAKE_SKIP_BUILD_RPATH FALSE)
  153. # when building, don't use the install RPATH already
  154. # (but later on when installing)
  155. set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  156. # set the RPATH to be used when installing
  157. if (NOT DEFINED GMT_INSTALL_RELOCATABLE)
  158. set (GMT_INSTALL_RELOCATABLE FALSE)
  159. endif (NOT DEFINED GMT_INSTALL_RELOCATABLE)
  160. if (GMT_INSTALL_RELOCATABLE)
  161. # make executables relocatable on supported platforms (relative RPATH)
  162. if (UNIX AND NOT CYGWIN)
  163. # find relative libdir from executable dir
  164. file (RELATIVE_PATH _rpath /${GMT_BINDIR} /${GMT_LIBDIR})
  165. # remove trailing /
  166. string (REGEX REPLACE "/$" "" _rpath "${_rpath}")
  167. if (APPLE)
  168. # relative RPATH on osx
  169. # CMP0042: CMake 3.0: MACOSX_RPATH is enabled by default
  170. set (CMAKE_MACOSX_RPATH ON)
  171. set (CMAKE_INSTALL_NAME_DIR @rpath)
  172. set (CMAKE_INSTALL_RPATH "@rpath;@executable_path/${_rpath}")
  173. else (APPLE)
  174. # relative RPATH on Linux, Solaris, etc.
  175. set (CMAKE_INSTALL_RPATH "\$ORIGIN/${_rpath}")
  176. endif (APPLE)
  177. endif (UNIX AND NOT CYGWIN)
  178. else (GMT_INSTALL_RELOCATABLE)
  179. # set absolute RPATH
  180. if (APPLE)
  181. # CMP0042: CMake 3.0: MACOSX_RPATH is enabled by default
  182. set (CMAKE_MACOSX_RPATH OFF)
  183. set (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${GMT_LIBDIR}")
  184. else (APPLE)
  185. # the RPATH to be used when installing, but only if it's not a
  186. # system directory
  187. list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
  188. "${CMAKE_INSTALL_PREFIX}/${GMT_LIBDIR}" isSystemDir)
  189. if ("${isSystemDir}" STREQUAL "-1")
  190. set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${GMT_LIBDIR}")
  191. endif ("${isSystemDir}" STREQUAL "-1")
  192. endif (APPLE)
  193. endif (GMT_INSTALL_RELOCATABLE)
  194. # add the automatically determined parts of the RPATH
  195. # which point to directories outside the build tree to the install RPATH
  196. set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  197. # When running examples/tests with CTest (out-of-source) we need support for
  198. # running GMT programs from within ${GMT_BINARY_DIR}:
  199. if (DO_EXAMPLES OR DO_TESTS AND NOT SUPPORT_EXEC_IN_BINARY_DIR)
  200. message (WARNING "Enabling SUPPORT_EXEC_IN_BINARY_DIR (required for "
  201. "testing). Please disable testing on release builds.")
  202. set (SUPPORT_EXEC_IN_BINARY_DIR ON)
  203. endif (DO_EXAMPLES OR DO_TESTS AND NOT SUPPORT_EXEC_IN_BINARY_DIR)
  204. # Make GNU and Intel C compiler default to C99
  205. if (CMAKE_C_COMPILER_ID MATCHES "(GNU|Intel)" AND NOT CMAKE_C_FLAGS MATCHES "-std=")
  206. set (CMAKE_C_FLAGS "-std=gnu99 ${CMAKE_C_FLAGS}")
  207. endif ()
  208. # Handle the special developer option GMT_DOCS_DEPEND_ON_GMT
  209. # Normally this is ON.
  210. if (NOT DEFINED GMT_DOCS_DEPEND_ON_GMT)
  211. set (GMT_DOCS_DEPEND_ON_GMT TRUE)
  212. endif (NOT DEFINED GMT_DOCS_DEPEND_ON_GMT)
  213. if (GMT_DOCS_DEPEND_ON_GMT)
  214. add_custom_target (gmt_for_img_convert DEPENDS gmt)
  215. else (GMT_DOCS_DEPEND_ON_GMT)
  216. add_custom_target (gmt_for_img_convert)
  217. endif (GMT_DOCS_DEPEND_ON_GMT)
  218. # 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...