comparison OrthancFramework/Resources/CMake/BoostConfigurationStatic-1.69.0.cmake @ 5063:cfbf45e76468

added CMake option USE_LEGACY_BOOST
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Aug 2022 12:20:00 +0200
parents OrthancFramework/Resources/CMake/BoostConfiguration.cmake@43e613a7756b
children 0ea402b4d901
comparison
equal deleted inserted replaced
5062:caed453042db 5063:cfbf45e76468
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2022 Osimis S.A., Belgium
5 # Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
6 #
7 # This program is free software: you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public License
9 # as published by the Free Software Foundation, either version 3 of
10 # the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program. If not, see
19 # <http://www.gnu.org/licenses/>.
20
21
22 if (BOOST_STATIC)
23 ##
24 ## Parameters for static compilation of Boost
25 ##
26
27 set(BOOST_NAME boost_1_69_0)
28 set(BOOST_VERSION 1.69.0)
29 set(BOOST_BCP_SUFFIX bcpdigest-1.5.6)
30 set(BOOST_MD5 "579bccc0ea4d1a261c1d0c5e27446c3d")
31 set(BOOST_URL "http://orthanc.osimis.io/ThirdPartyDownloads/${BOOST_NAME}_${BOOST_BCP_SUFFIX}.tar.gz")
32 set(BOOST_SOURCES_DIR ${CMAKE_BINARY_DIR}/${BOOST_NAME})
33
34 if (IS_DIRECTORY "${BOOST_SOURCES_DIR}")
35 set(FirstRun OFF)
36 else()
37 set(FirstRun ON)
38 endif()
39
40 DownloadPackage(${BOOST_MD5} ${BOOST_URL} "${BOOST_SOURCES_DIR}")
41
42
43 ##
44 ## Patching boost
45 ##
46
47 execute_process(
48 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
49 ${CMAKE_CURRENT_LIST_DIR}/../Patches/boost-${BOOST_VERSION}-linux-standard-base.patch
50 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
51 RESULT_VARIABLE Failure
52 )
53
54 if (FirstRun AND Failure)
55 message(FATAL_ERROR "Error while patching a file")
56 endif()
57
58
59 ##
60 ## Generic configuration of Boost
61 ##
62
63 if (CMAKE_COMPILER_IS_GNUCXX)
64 add_definitions(-isystem ${BOOST_SOURCES_DIR})
65 endif()
66
67 include_directories(
68 BEFORE ${BOOST_SOURCES_DIR}
69 )
70
71 if (ORTHANC_BUILDING_FRAMEWORK_LIBRARY)
72 add_definitions(
73 # Packaging Boost inside the Orthanc Framework DLL
74 -DBOOST_ALL_DYN_LINK # Expose Boost symbols into the DLL
75 -DBOOST_THREAD_BUILD_DLL
76 -DBOOST_REGEX_BUILD_DLL
77 -DBOOST_IOSTREAMS_SOURCE
78 )
79 else()
80 add_definitions(
81 # Static build of Boost (this was the only possibility in
82 # Orthanc <= 1.7.1)
83 -DBOOST_ALL_NO_LIB
84 -DBOOST_ALL_NOLIB
85 -DBOOST_DATE_TIME_NO_LIB
86 -DBOOST_THREAD_BUILD_LIB
87 -DBOOST_PROGRAM_OPTIONS_NO_LIB
88 -DBOOST_REGEX_NO_LIB
89 -DBOOST_SYSTEM_NO_LIB
90 -DBOOST_LOCALE_NO_LIB
91 )
92 endif()
93
94 add_definitions(
95 # In static builds, explicitly prevent Boost from using the system
96 # locale in lexical casts. This is notably important if
97 # "boost::lexical_cast<double>()" is applied to strings containing
98 # "," instead of "." as decimal separators. Check out function
99 # "OrthancStone::LinearAlgebra::ParseVector()".
100 -DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE
101 )
102
103 set(BOOST_SOURCES
104 ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp
105 )
106
107 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase" OR
108 "${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
109 add_definitions(
110 -DBOOST_SYSTEM_USE_STRERROR=1
111 )
112 endif()
113
114
115 ##
116 ## Configuration of boost::thread
117 ##
118
119 if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
120 CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
121 CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
122 CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD" OR
123 CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
124 CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
125 CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
126 CMAKE_SYSTEM_NAME STREQUAL "NaCl64" OR
127 CMAKE_SYSTEM_NAME STREQUAL "Android")
128 list(APPEND BOOST_SOURCES
129 ${BOOST_SOURCES_DIR}/libs/atomic/src/lockpool.cpp
130 ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/once.cpp
131 ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/thread.cpp
132 )
133
134 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase" OR
135 CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
136 CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
137 CMAKE_SYSTEM_NAME STREQUAL "NaCl64")
138 add_definitions(-DBOOST_HAS_SCHED_YIELD=1)
139 endif()
140
141 # Fix for error: "boost_1_69_0/boost/chrono/detail/inlined/mac/thread_clock.hpp:54:28:
142 # error: use of undeclared identifier 'pthread_mach_thread_np'"
143 # https://github.com/envoyproxy/envoy/pull/1785
144 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
145 add_definitions(-D_DARWIN_C_SOURCE=1)
146 endif()
147
148 elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
149 list(APPEND BOOST_SOURCES
150 ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_dll.cpp
151 ${BOOST_SOURCES_DIR}/libs/thread/src/win32/thread.cpp
152 ${BOOST_SOURCES_DIR}/libs/thread/src/win32/tss_pe.cpp
153 )
154
155 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
156 # No support for threads in asm.js/WebAssembly
157
158 else()
159 message(FATAL_ERROR "Support your platform here")
160 endif()
161
162
163 ##
164 ## Configuration of boost::regex
165 ##
166
167 aux_source_directory(${BOOST_SOURCES_DIR}/libs/regex/src BOOST_REGEX_SOURCES)
168
169 list(APPEND BOOST_SOURCES
170 ${BOOST_REGEX_SOURCES}
171 )
172
173
174 ##
175 ## Configuration of boost::datetime
176 ##
177
178 list(APPEND BOOST_SOURCES
179 ${BOOST_SOURCES_DIR}/libs/date_time/src/gregorian/greg_month.cpp
180 )
181
182
183 ##
184 ## Configuration of boost::filesystem and boost::iostreams
185 ##
186
187 if (CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
188 CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
189 CMAKE_SYSTEM_NAME STREQUAL "NaCl64" OR
190 CMAKE_SYSTEM_NAME STREQUAL "Android")
191 # boost::filesystem is not available on PNaCl
192 add_definitions(
193 -DBOOST_HAS_FILESYSTEM_V3=0
194 -D__INTEGRITY=1
195 )
196 else()
197 add_definitions(
198 -DBOOST_HAS_FILESYSTEM_V3=1
199 )
200 list(APPEND BOOST_SOURCES
201 ${BOOST_NAME}/libs/filesystem/src/codecvt_error_category.cpp
202 ${BOOST_NAME}/libs/filesystem/src/operations.cpp
203 ${BOOST_NAME}/libs/filesystem/src/path.cpp
204 ${BOOST_NAME}/libs/filesystem/src/path_traits.cpp
205 )
206
207 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
208 CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
209 CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
210 list(APPEND BOOST_SOURCES
211 ${BOOST_SOURCES_DIR}/libs/filesystem/src/utf8_codecvt_facet.cpp
212 )
213
214 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
215 list(APPEND BOOST_SOURCES
216 ${BOOST_NAME}/libs/filesystem/src/windows_file_codecvt.cpp
217 )
218 endif()
219 endif()
220
221 list(APPEND BOOST_SOURCES
222 ${BOOST_NAME}/libs/iostreams/src/file_descriptor.cpp
223 )
224
225
226 ##
227 ## Configuration of boost::locale
228 ##
229
230 if (NOT ENABLE_LOCALE)
231 message("boost::locale is disabled")
232 else()
233 set(BOOST_ICU_SOURCES
234 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/boundary.cpp
235 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/codecvt.cpp
236 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/collator.cpp
237 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/conversion.cpp
238 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/date_time.cpp
239 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/formatter.cpp
240 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/icu_backend.cpp
241 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/numeric.cpp
242 ${BOOST_SOURCES_DIR}/libs/locale/src/icu/time_zone.cpp
243 )
244
245 list(APPEND BOOST_SOURCES
246 ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp
247 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/generator.cpp
248 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/date_time.cpp
249 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/formatting.cpp
250 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/ids.cpp
251 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/localization_backend.cpp
252 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/message.cpp
253 ${BOOST_SOURCES_DIR}/libs/locale/src/shared/mo_lambda.cpp
254 ${BOOST_SOURCES_DIR}/libs/locale/src/util/codecvt_converter.cpp
255 ${BOOST_SOURCES_DIR}/libs/locale/src/util/default_locale.cpp
256 ${BOOST_SOURCES_DIR}/libs/locale/src/util/gregorian.cpp
257 ${BOOST_SOURCES_DIR}/libs/locale/src/util/info.cpp
258 ${BOOST_SOURCES_DIR}/libs/locale/src/util/locale_data.cpp
259 )
260
261 if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
262 CMAKE_SYSTEM_VERSION STREQUAL "LinuxStandardBase")
263 add_definitions(
264 -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
265 -DBOOST_LOCALE_NO_POSIX_BACKEND=1
266 )
267
268 list(APPEND BOOST_SOURCES
269 ${BOOST_SOURCES_DIR}/libs/locale/src/std/codecvt.cpp
270 ${BOOST_SOURCES_DIR}/libs/locale/src/std/collate.cpp
271 ${BOOST_SOURCES_DIR}/libs/locale/src/std/converter.cpp
272 ${BOOST_SOURCES_DIR}/libs/locale/src/std/numeric.cpp
273 ${BOOST_SOURCES_DIR}/libs/locale/src/std/std_backend.cpp
274 )
275
276 if (BOOST_LOCALE_BACKEND STREQUAL "gcc" OR
277 BOOST_LOCALE_BACKEND STREQUAL "libiconv")
278 add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
279 elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
280 add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
281 list(APPEND BOOST_SOURCES ${BOOST_ICU_SOURCES})
282 else()
283 message(FATAL_ERROR "Unsupported value for BOOST_LOCALE_BACKEND: ${BOOST_LOCALE_BACKEND}")
284 endif()
285
286 elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
287 CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
288 CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
289 CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD" OR
290 CMAKE_SYSTEM_NAME STREQUAL "PNaCl" OR
291 CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
292 CMAKE_SYSTEM_NAME STREQUAL "NaCl64" OR
293 CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # For WebAssembly or asm.js
294 add_definitions(
295 -DBOOST_LOCALE_NO_WINAPI_BACKEND=1
296 -DBOOST_LOCALE_NO_STD_BACKEND=1
297 )
298
299 list(APPEND BOOST_SOURCES
300 ${BOOST_SOURCES_DIR}/libs/locale/src/posix/codecvt.cpp
301 ${BOOST_SOURCES_DIR}/libs/locale/src/posix/collate.cpp
302 ${BOOST_SOURCES_DIR}/libs/locale/src/posix/converter.cpp
303 ${BOOST_SOURCES_DIR}/libs/locale/src/posix/numeric.cpp
304 ${BOOST_SOURCES_DIR}/libs/locale/src/posix/posix_backend.cpp
305 )
306
307 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" OR
308 BOOST_LOCALE_BACKEND STREQUAL "gcc" OR
309 BOOST_LOCALE_BACKEND STREQUAL "libiconv")
310 # In WebAssembly or asm.js, we rely on the version of iconv
311 # that is shipped with the stdlib
312 add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
313 elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
314 add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
315 list(APPEND BOOST_SOURCES ${BOOST_ICU_SOURCES})
316 else()
317 message(FATAL_ERROR "Unsupported value for BOOST_LOCALE_BACKEND: ${BOOST_LOCALE_BACKEND}")
318 endif()
319
320 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
321 add_definitions(
322 -DBOOST_LOCALE_NO_POSIX_BACKEND=1
323 -DBOOST_LOCALE_NO_STD_BACKEND=1
324 )
325
326 list(APPEND BOOST_SOURCES
327 ${BOOST_SOURCES_DIR}/libs/locale/src/win32/collate.cpp
328 ${BOOST_SOURCES_DIR}/libs/locale/src/win32/converter.cpp
329 ${BOOST_SOURCES_DIR}/libs/locale/src/win32/lcid.cpp
330 ${BOOST_SOURCES_DIR}/libs/locale/src/win32/numeric.cpp
331 ${BOOST_SOURCES_DIR}/libs/locale/src/win32/win_backend.cpp
332 )
333
334 # Starting with release 0.8.2, Orthanc statically links against
335 # libiconv on Windows. Indeed, the "WCONV" library of Windows XP
336 # seems not to support properly several codepages (notably
337 # "Latin3", "Hebrew", and "Arabic"). Set "BOOST_LOCALE_BACKEND"
338 # to "wconv" to use WCONV anyway.
339
340 if (BOOST_LOCALE_BACKEND STREQUAL "libiconv")
341 add_definitions(-DBOOST_LOCALE_WITH_ICONV=1)
342 elseif (BOOST_LOCALE_BACKEND STREQUAL "icu")
343 add_definitions(-DBOOST_LOCALE_WITH_ICU=1)
344 list(APPEND BOOST_SOURCES ${BOOST_ICU_SOURCES})
345 elseif (BOOST_LOCALE_BACKEND STREQUAL "wconv")
346 message("Using Window's wconv")
347 add_definitions(-DBOOST_LOCALE_WITH_WCONV=1)
348 else()
349 message(FATAL_ERROR "Unsupported value for BOOST_LOCALE_BACKEND on Windows: ${BOOST_LOCALE_BACKEND}")
350 endif()
351
352 else()
353 message(FATAL_ERROR "Support your platform here")
354 endif()
355 endif()
356
357
358 source_group(ThirdParty\\boost REGULAR_EXPRESSION ${BOOST_SOURCES_DIR}/.*)
359
360 endif()