20
20
# along with this program; if not, write to the Free Software
21
21
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
22
23
- # We want boost 1.77.0 in order to build our boost/geometry code.
24
- # The boost tarball is fairly big, and takes several minutes
25
- # to download. So we recommend downloading/unpacking it
26
- # only once, in a place visible from any git sandbox.
27
- # We use only header files, so there should be no binary dependencies.
28
-
29
- # Downloading the tarball takes about 5 minutes here at the office.
30
- # Here are some size/time data for unpacking the tarball on my desktop:
31
- # size tarball-name
32
- # 67M boost_1_55_0.tar.gz unzipping headers ~2 seconds 117M
33
- # unzipping everything ~3 seconds 485M
34
- # 8,8M boost_headers.tar.gz unzipping everything <1 second
35
-
36
- # Invoke with -DWITH_BOOST=<directory> or set WITH_BOOST in environment.
37
- # If WITH_BOOST is *not* set, or is set to the special value "system",
38
- # we assume that the correct version (see below)
39
- # is installed on the compile host in the standard location.
40
-
41
23
SET (BOOST_PACKAGE_NAME "boost_1_77_0" )
42
- SET (BOOST_TARBALL "${BOOST_PACKAGE_NAME} .tar.bz2" )
43
- SET (BOOST_DOWNLOAD_URL
44
- "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/${BOOST_TARBALL} "
45
- )
46
-
47
- SET (OLD_PACKAGE_NAMES
48
- "boost_1_55_0"
49
- "boost_1_56_0"
50
- "boost_1_57_0"
51
- "boost_1_58_0"
52
- "boost_1_59_0"
53
- "boost_1_60_0"
54
- "boost_1_61_0"
55
- "boost_1_62_0"
56
- "boost_1_63_0"
57
- "boost_1_64_0"
58
- "boost_1_65_0"
59
- "boost_1_66_0"
60
- "boost_1_67_0"
61
- "boost_1_68_0"
62
- "boost_1_69_0"
63
- "boost_1_70_0"
64
- "boost_1_71_0"
65
- "boost_1_72_0"
66
- "boost_1_73_0"
67
- )
68
-
69
- MACRO (RESET_BOOST_VARIABLES )
70
- UNSET (BOOST_INCLUDE_DIR )
71
- UNSET (BOOST_INCLUDE_DIR CACHE )
72
- UNSET (LOCAL_BOOST_DIR )
73
- UNSET (LOCAL_BOOST_DIR CACHE )
74
- UNSET (LOCAL_BOOST_ZIP )
75
- UNSET (LOCAL_BOOST_ZIP CACHE )
76
- ENDMACRO ()
77
-
78
- MACRO (ECHO_BOOST_VARIABLES )
79
- MESSAGE (STATUS "BOOST_INCLUDE_DIR ${BOOST_INCLUDE_DIR} " )
80
- MESSAGE (STATUS "LOCAL_BOOST_DIR ${LOCAL_BOOST_DIR} " )
81
- MESSAGE (STATUS "LOCAL_BOOST_ZIP ${LOCAL_BOOST_ZIP} " )
82
- ENDMACRO ()
83
-
84
- MACRO (LOOKUP_OLD_PACKAGE_NAMES )
85
- FOREACH (pkg ${OLD_PACKAGE_NAMES} )
86
- FIND_FILE (OLD_BOOST_DIR
87
- NAMES "${pkg} "
88
- PATHS ${WITH_BOOST}
89
- NO_DEFAULT_PATH
90
- )
91
- IF (OLD_BOOST_DIR )
92
- MESSAGE (STATUS "" )
93
- MESSAGE (STATUS "Found old boost installation at ${OLD_BOOST_DIR} " )
94
- MESSAGE (STATUS "You must upgrade to ${BOOST_PACKAGE_NAME} " )
95
- MESSAGE (STATUS "" )
96
- ENDIF ()
97
- UNSET (OLD_BOOST_DIR )
98
- UNSET (OLD_BOOST_DIR CACHE )
99
- ENDFOREACH ()
100
- ENDMACRO ()
101
-
102
- MACRO (COULD_NOT_FIND_BOOST )
103
- LOOKUP_OLD_PACKAGE_NAMES ()
104
- ECHO_BOOST_VARIABLES ()
105
- RESET_BOOST_VARIABLES ()
106
- MESSAGE (STATUS "Could not find (the correct version of) boost." )
107
- MESSAGE (STATUS "MySQL currently requires ${BOOST_PACKAGE_NAME} \n " )
108
- MESSAGE (FATAL_ERROR
109
- "You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>\n "
110
- "This CMake script will look for boost in <directory>. "
111
- "If it is not there, it will download and unpack it "
112
- "(in that directory) for you.\n "
113
- "You can also download boost manually, from ${BOOST_DOWNLOAD_URL} \n "
114
- "If you are inside a firewall, you may need to use an https proxy:\n "
115
- "export https_proxy=http://example.com:80\n "
116
- )
117
- ENDMACRO ()
118
-
119
- # Pick value from environment if not set on command line.
120
- IF (DEFINED ENV{WITH_BOOST} AND NOT DEFINED WITH_BOOST )
121
- SET (WITH_BOOST "$ENV{WITH_BOOST} " )
122
- ENDIF ()
123
-
124
- # Pick value from environment if not set on command line.
125
- IF (DEFINED ENV{BOOST_ROOT} AND NOT DEFINED WITH_BOOST )
126
- SET (WITH_BOOST "$ENV{BOOST_ROOT} " )
127
- ENDIF ()
128
-
129
- IF (WITH_BOOST AND WITH_BOOST STREQUAL "system" )
130
- UNSET (WITH_BOOST )
131
- UNSET (WITH_BOOST CACHE )
132
- ENDIF ()
133
-
134
- # Update the cache, to make it visible in cmake-gui.
135
- SET (WITH_BOOST ${WITH_BOOST} CACHE PATH
136
- "Path to boost sources: a directory, or a tarball to be unzipped." )
137
-
138
- # If the value of WITH_BOOST changes, we must unset all dependent variables:
139
- IF (OLD_WITH_BOOST )
140
- IF (NOT "${OLD_WITH_BOOST} " STREQUAL "${WITH_BOOST} " )
141
- RESET_BOOST_VARIABLES ()
142
- ENDIF ()
143
- ENDIF ()
144
-
145
- SET (OLD_WITH_BOOST ${WITH_BOOST} CACHE INTERNAL
146
- "Previous version of WITH_BOOST" FORCE )
147
24
148
- IF (WITH_BOOST )
149
- ## Did we get a full path name, including file name?
150
- IF (${WITH_BOOST} MATCHES ".*\\ .tar.bz2" OR ${WITH_BOOST} MATCHES ".*\\ .zip" )
151
- GET_FILENAME_COMPONENT (BOOST_DIR ${WITH_BOOST} PATH )
152
- GET_FILENAME_COMPONENT (BOOST_ZIP ${WITH_BOOST} NAME )
153
- FIND_FILE (LOCAL_BOOST_ZIP
154
- NAMES ${BOOST_ZIP}
155
- PATHS ${BOOST_DIR}
156
- NO_DEFAULT_PATH
157
- )
158
- ENDIF ()
159
- ## Did we get a path name to the directory of the .tar.bz2 or .zip file?
160
- FIND_FILE (LOCAL_BOOST_ZIP
161
- NAMES "${BOOST_PACKAGE_NAME} .tar.bz2" "${BOOST_PACKAGE_NAME} .zip"
162
- PATHS ${WITH_BOOST}
163
- NO_DEFAULT_PATH
164
- )
165
- ## Did we get a path name to the directory of an unzipped version?
166
- FIND_FILE (LOCAL_BOOST_DIR
167
- NAMES "${BOOST_PACKAGE_NAME} "
168
- PATHS ${WITH_BOOST}
169
- NO_DEFAULT_PATH
170
- )
171
- ## Did we get a path name to an unzippped version?
172
- FIND_PATH (LOCAL_BOOST_DIR
173
- NAMES "boost/version.hpp"
174
- PATHS ${WITH_BOOST}
175
- NO_DEFAULT_PATH
176
- )
177
- IF (LOCAL_BOOST_DIR )
178
- MESSAGE (STATUS "Local boost dir ${LOCAL_BOOST_DIR} " )
179
- ENDIF ()
180
- IF (LOCAL_BOOST_ZIP )
181
- MESSAGE (STATUS "Local boost zip ${LOCAL_BOOST_ZIP} " )
182
- GET_FILE_SIZE (${LOCAL_BOOST_ZIP} LOCAL_BOOST_ZIP_SIZE )
183
- IF (LOCAL_BOOST_ZIP_SIZE EQUAL 0 )
184
- # A previous failed download has left an empty file, most likely the
185
- # user pressed Ctrl-C to kill a hanging connection due to missing vpn
186
- # proxy. Remove it!
187
- MESSAGE ("${LOCAL_BOOST_ZIP} is zero length. Deleting it." )
188
- FILE (REMOVE ${WITH_BOOST} /${BOOST_TARBALL} )
189
- UNSET (LOCAL_BOOST_ZIP )
190
- UNSET (LOCAL_BOOST_ZIP CACHE )
191
- ENDIF ()
192
- UNSET (LOCAL_BOOST_ZIP_ZERO_LENGTH )
193
- ENDIF ()
194
- ENDIF ()
195
-
196
- # There is a similar option in unittest/gunit.
197
- # But the boost tarball is much bigger, so we have a separate option.
198
- OPTION (DOWNLOAD_BOOST "Download boost from sourceforge." OFF )
199
- SET (DOWNLOAD_BOOST_TIMEOUT 600 CACHE STRING
200
- "Timeout in seconds when downloading boost." )
201
-
202
- # If we could not find it, then maybe download it.
203
- IF (WITH_BOOST AND NOT LOCAL_BOOST_ZIP AND NOT LOCAL_BOOST_DIR )
204
- IF (NOT DOWNLOAD_BOOST )
205
- MESSAGE (STATUS "WITH_BOOST=${WITH_BOOST} " )
206
- COULD_NOT_FIND_BOOST ()
207
- ENDIF ()
208
- # Download the tarball
209
- MESSAGE (STATUS "Downloading ${BOOST_TARBALL} to ${WITH_BOOST} " )
210
- FILE (DOWNLOAD ${BOOST_DOWNLOAD_URL}
211
- ${WITH_BOOST} /${BOOST_TARBALL}
212
- TIMEOUT ${DOWNLOAD_BOOST_TIMEOUT}
213
- STATUS ERR
214
- SHOW_PROGRESS
215
- )
216
- IF (ERR EQUAL 0 )
217
- SET (LOCAL_BOOST_ZIP "${WITH_BOOST} /${BOOST_TARBALL} " )
218
- SET (LOCAL_BOOST_ZIP "${WITH_BOOST} /${BOOST_TARBALL} " CACHE INTERNAL "" )
219
- ELSE ()
220
- MESSAGE (STATUS "Download failed, error: ${ERR} " )
221
- # A failed DOWNLOAD leaves an empty file, remove it
222
- FILE (REMOVE ${WITH_BOOST} /${BOOST_TARBALL} )
223
- # STATUS returns a list of length 2
224
- LIST (GET ERR 0 NUMERIC_RETURN )
225
- IF (NUMERIC_RETURN EQUAL 28 )
226
- MESSAGE (FATAL_ERROR
227
- "You can try downloading ${BOOST_DOWNLOAD_URL} manually"
228
- " using curl/wget or a similar tool,"
229
- " or increase the value of DOWNLOAD_BOOST_TIMEOUT"
230
- " (which is now ${DOWNLOAD_BOOST_TIMEOUT} seconds)"
231
- )
232
- ENDIF ()
233
- MESSAGE (FATAL_ERROR
234
- "You can try downloading ${BOOST_DOWNLOAD_URL} manually"
235
- " using curl/wget or a similar tool"
236
- )
237
- ENDIF ()
238
- ENDIF ()
239
-
240
- IF (LOCAL_BOOST_ZIP AND NOT LOCAL_BOOST_DIR )
241
- GET_FILENAME_COMPONENT (LOCAL_BOOST_DIR ${LOCAL_BOOST_ZIP} PATH )
242
- IF (NOT EXISTS "${LOCAL_BOOST_DIR} /${BOOST_PACKAGE_NAME} " )
243
- MESSAGE (STATUS "cd ${LOCAL_BOOST_DIR} ; tar xfj ${LOCAL_BOOST_ZIP} " )
244
- EXECUTE_PROCESS (
245
- COMMAND ${CMAKE_COMMAND} -E tar xfj "${LOCAL_BOOST_ZIP} "
246
- WORKING_DIRECTORY "${LOCAL_BOOST_DIR} "
247
- RESULT_VARIABLE tar_result
248
- )
249
- IF (tar_result MATCHES 0 )
250
- SET (BOOST_FOUND 1 CACHE INTERNAL "" )
251
- ELSE ()
252
- MESSAGE (STATUS "WITH_BOOST ${WITH_BOOST} ." )
253
- MESSAGE (STATUS "Failed to extract files.\n "
254
- " Please try downloading and extracting yourself.\n "
255
- " The url is: ${BOOST_DOWNLOAD_URL} " )
256
- MESSAGE (FATAL_ERROR "Giving up." )
257
- ENDIF ()
258
- ENDIF ()
259
- ENDIF ()
260
-
261
- # Search for the version file, first in LOCAL_BOOST_DIR or WITH_BOOST
262
- FIND_PATH (BOOST_INCLUDE_DIR
263
- NAMES boost/version.hpp
264
- NO_DEFAULT_PATH
265
- PATHS ${LOCAL_BOOST_DIR}
266
- ${LOCAL_BOOST_DIR} /${BOOST_PACKAGE_NAME}
267
- ${WITH_BOOST}
268
- )
269
- # Then search in standard places (if not found above).
270
- FIND_PATH (BOOST_INCLUDE_DIR
271
- NAMES boost/version.hpp
272
- )
25
+ # Always use the bundled version.
26
+ SET (BOOST_SOURCE_DIR ${CMAKE_SOURCE_DIR} /extra/boost )
273
27
274
- IF (NOT BOOST_INCLUDE_DIR )
275
- MESSAGE (STATUS
276
- "Looked for boost/version.hpp in ${LOCAL_BOOST_DIR} and ${WITH_BOOST} " )
277
- COULD_NOT_FIND_BOOST ()
278
- ELSE ()
279
- MESSAGE (STATUS "Found ${BOOST_INCLUDE_DIR} /boost/version.hpp " )
280
- ENDIF ()
28
+ # Contains all header files we need.
29
+ # (All the directories that contain at least one needed file).
30
+ SET (BOOST_INCLUDE_DIR ${BOOST_SOURCE_DIR} /${BOOST_PACKAGE_NAME} )
281
31
282
- # Verify version number. Version information looks like:
283
- # // BOOST_VERSION % 100 is the patch level
284
- # // BOOST_VERSION / 100 % 1000 is the minor version
285
- # // BOOST_VERSION / 100000 is the major version
286
- # #define BOOST_VERSION 107700
287
- FILE (STRINGS "${BOOST_INCLUDE_DIR} /boost/version.hpp"
288
- BOOST_VERSION_NUMBER
289
- REGEX "^#define[\t ]+BOOST_VERSION[\t ][0-9]+.*"
290
- )
291
- STRING (REGEX REPLACE
292
- "^.*BOOST_VERSION[\t ]([0-9][0-9])([0-9][0-9])([0-9][0-9]).*$" "\\ 1"
293
- BOOST_MAJOR_VERSION "${BOOST_VERSION_NUMBER} " )
294
- STRING (REGEX REPLACE
295
- "^.*BOOST_VERSION[\t ]([0-9][0-9])([0-9][0-9])([0-9][0-9]).*$" "\\ 2"
296
- BOOST_MINOR_VERSION "${BOOST_VERSION_NUMBER} " )
297
-
298
- MESSAGE (STATUS "BOOST_VERSION_NUMBER is ${BOOST_VERSION_NUMBER} " )
32
+ # We have a limited set of patches/bugfixes here:
33
+ SET (BOOST_PATCHES_DIR
34
+ "${CMAKE_SOURCE_DIR} /include/${BOOST_PACKAGE_NAME} /patches" )
299
35
300
- IF (NOT BOOST_MAJOR_VERSION EQUAL 10 )
301
- COULD_NOT_FIND_BOOST ()
302
- ENDIF ()
36
+ ADD_LIBRARY (boost INTERFACE )
37
+ ADD_LIBRARY (extra::boost ALIAS boost )
303
38
304
- IF (NOT BOOST_MINOR_VERSION EQUAL 77 )
305
- MESSAGE (WARNING "Boost minor version found is ${BOOST_MINOR_VERSION} "
306
- "we need 77"
307
- )
308
- COULD_NOT_FIND_BOOST ()
309
- ENDIF ()
39
+ TARGET_INCLUDE_DIRECTORIES (boost SYSTEM BEFORE INTERFACE
40
+ ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR} )
310
41
42
+ MESSAGE (STATUS "BOOST_PATCHES_DIR ${BOOST_PATCHES_DIR} " )
311
43
MESSAGE (STATUS "BOOST_INCLUDE_DIR ${BOOST_INCLUDE_DIR} " )
312
44
313
- # We have a limited set of patches/bugfixes here:
314
- SET (BOOST_PATCHES_DIR "${CMAKE_SOURCE_DIR} /include/boost_1_77_0/patches" )
315
-
316
- # Boost gets confused about language support with Clang 7 + MSVC 15.9
317
- IF (WIN32_CLANG )
318
- ADD_DEFINITIONS (-DBOOST_NO_CXX17_HDR_STRING_VIEW )
319
- ENDIF ()
320
-
321
- IF (LOCAL_BOOST_DIR OR LOCAL_BOOST_ZIP )
322
- SET (USING_LOCAL_BOOST 1 )
323
- ELSE ()
324
- SET (USING_SYSTEM_BOOST 1 )
325
- ENDIF ()
326
-
327
45
IF (NOT WIN32 )
328
- # Needed to use Boost header container_hash/hash.hpp in C++17
329
- ADD_DEFINITIONS (-DBOOST_NO_CXX98_FUNCTION_BASE )
330
-
331
46
FILE (GLOB_RECURSE BOOST_PATCHES_LIST
332
47
RELATIVE ${BOOST_PATCHES_DIR}
333
48
${BOOST_PATCHES_DIR} /*.hpp
@@ -337,7 +52,8 @@ IF(NOT WIN32)
337
52
FOREACH (PATCHED_FILE ${BOOST_PATCHES_LIST} )
338
53
SET (ORIGINAL_FILE_PATH "${BOOST_INCLUDE_DIR} /${PATCHED_FILE} " )
339
54
SET (PATCHED_FILE_PATH "${BOOST_PATCHES_DIR} /${PATCHED_FILE} " )
340
- LIST (APPEND DIFF_COMMAND_LIST "diff -u ${ORIGINAL_FILE_PATH} ${PATCHED_FILE_PATH} " )
55
+ LIST (APPEND DIFF_COMMAND_LIST
56
+ "diff -u ${ORIGINAL_FILE_PATH} ${PATCHED_FILE_PATH} " )
341
57
ENDFOREACH ()
342
58
# Add true, to get zero exit status.
343
59
LIST (APPEND DIFF_COMMAND_LIST "true" )
0 commit comments