Mercurial > hg > orthanc
annotate OrthancFramework/Resources/CMake/DcmtkConfigurationStatic-3.6.7.cmake @ 5253:1700fe5c9737 db-protobuf
integration mainline->db-protobuf
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 08 Apr 2023 11:44:05 +0200 |
parents | 0ea402b4d901 |
children | c5f243ad7103 |
rev | line source |
---|---|
5067 | 1 # Orthanc - A Lightweight, RESTful DICOM Store |
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
3 # Department, University Hospital of Liege, Belgium | |
5185
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5075
diff
changeset
|
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
0ea402b4d901
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5075
diff
changeset
|
5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
5067 | 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 SET(DCMTK_VERSION_NUMBER 367) | |
23 SET(DCMTK_PACKAGE_VERSION "3.6.7") | |
24 SET(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.7) | |
25 SET(DCMTK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/dcmtk-3.6.7.tar.gz") | |
26 SET(DCMTK_MD5 "e4d519bb315ec3944f3f1d61df465cbd") | |
27 | |
28 macro(DCMTK_UNSET) | |
29 endmacro() | |
30 | |
31 macro(DCMTK_UNSET_CACHE) | |
32 endmacro() | |
33 | |
34 set(DCMTK_BINARY_DIR ${DCMTK_SOURCES_DIR}/) | |
35 set(DCMTK_CMAKE_INCLUDE ${DCMTK_SOURCES_DIR}/) | |
36 | |
37 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | |
38 set(DCMTK_WITH_THREADS OFF) # Disable thread support in wasm/asm.js | |
39 else() | |
40 set(DCMTK_WITH_THREADS ON) | |
41 endif() | |
42 | |
43 add_definitions(-DDCMTK_INSIDE_LOG4CPLUS=1) | |
44 | |
45 if (IS_DIRECTORY "${DCMTK_SOURCES_DIR}") | |
46 set(FirstRun OFF) | |
47 else() | |
48 set(FirstRun ON) | |
49 endif() | |
50 | |
51 DownloadPackage(${DCMTK_MD5} ${DCMTK_URL} "${DCMTK_SOURCES_DIR}") | |
52 | |
53 | |
54 if (FirstRun) | |
55 # Apply the patches | |
56 execute_process( | |
57 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i | |
58 ${CMAKE_CURRENT_LIST_DIR}/../Patches/dcmtk-3.6.7.patch | |
59 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
60 RESULT_VARIABLE Failure | |
61 ) | |
62 | |
63 if (Failure) | |
64 message(FATAL_ERROR "Error while patching a file") | |
65 endif() | |
66 | |
5075
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
67 if (MSVC) |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
68 # Older versions of Microsoft Visual Studio (notably MSVC2008) |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
69 # don't like void usage of function arguments in C source files, |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
70 # in order to avoid a warning about unused arguments. This patch |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
71 # removes such usages that were not present in DCMTK <= 3.6.6. |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
72 execute_process( |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
73 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
74 ${CMAKE_CURRENT_LIST_DIR}/../Patches/dcmtk-3.6.7-visual-studio.patch |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
75 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
76 RESULT_VARIABLE Failure |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
77 ) |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
78 |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
79 if (Failure) |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
80 message(FATAL_ERROR "Error while patching a file") |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
81 endif() |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
82 endif() |
a342e561c29d
fix MSVC2008 build
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5072
diff
changeset
|
83 |
5067 | 84 configure_file( |
85 ${CMAKE_CURRENT_LIST_DIR}/../Patches/dcmtk-dcdict_orthanc.cc | |
86 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdict_orthanc.cc | |
87 COPYONLY) | |
88 else() | |
89 message("The patches for DCMTK have already been applied") | |
90 endif() | |
91 | |
92 | |
93 include_directories( | |
94 ${DCMTK_SOURCES_DIR}/dcmiod/include | |
95 ) | |
96 | |
97 | |
98 # C_CHAR_UNSIGNED *must* be set before calling "GenerateDCMTKConfigure.cmake" | |
99 IF (CMAKE_CROSSCOMPILING) | |
100 if (CMAKE_COMPILER_IS_GNUCXX AND | |
101 CMAKE_SYSTEM_NAME STREQUAL "Windows") # MinGW | |
102 SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.") | |
103 | |
104 elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or asm.js | |
105 | |
106 # Check out "../WebAssembly/ArithmeticTests/" to regenerate the | |
107 # "arith.h" file | |
108 configure_file( | |
109 ${CMAKE_CURRENT_LIST_DIR}/WebAssembly/arith.h | |
110 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/arith.h | |
111 COPYONLY) | |
112 | |
113 UNSET(C_CHAR_UNSIGNED CACHE) | |
114 SET(C_CHAR_UNSIGNED 0 CACHE INTERNAL "") | |
115 | |
116 else() | |
117 message(FATAL_ERROR "Support your platform here") | |
118 endif() | |
119 ENDIF() | |
120 | |
121 | |
122 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | |
123 SET(DCMTK_ENABLE_CHARSET_CONVERSION "iconv" CACHE STRING "") | |
124 SET(HAVE_SYS_GETTID 0 CACHE INTERNAL "") | |
125 endif() | |
126 | |
127 | |
128 SET(DCMTK_SOURCE_DIR ${DCMTK_SOURCES_DIR}) | |
129 include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake) | |
130 include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake) | |
131 | |
132 | |
133 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or | |
134 # asm.js The macros below are not properly discovered by DCMTK | |
135 # when using WebAssembly. Check out "../WebAssembly/arith.h" for | |
136 # how we produced these values. This step MUST be after | |
137 # "GenerateDCMTKConfigure" and before the generation of | |
138 # "osconfig.h". | |
139 UNSET(SIZEOF_VOID_P CACHE) | |
140 UNSET(SIZEOF_CHAR CACHE) | |
141 UNSET(SIZEOF_DOUBLE CACHE) | |
142 UNSET(SIZEOF_FLOAT CACHE) | |
143 UNSET(SIZEOF_INT CACHE) | |
144 UNSET(SIZEOF_LONG CACHE) | |
145 UNSET(SIZEOF_SHORT CACHE) | |
146 UNSET(SIZEOF_VOID_P CACHE) | |
147 | |
148 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "") | |
149 SET(SIZEOF_CHAR 1 CACHE INTERNAL "") | |
150 SET(SIZEOF_DOUBLE 8 CACHE INTERNAL "") | |
151 SET(SIZEOF_FLOAT 4 CACHE INTERNAL "") | |
152 SET(SIZEOF_INT 4 CACHE INTERNAL "") | |
153 SET(SIZEOF_LONG 4 CACHE INTERNAL "") | |
154 SET(SIZEOF_SHORT 2 CACHE INTERNAL "") | |
155 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "") | |
156 endif() | |
157 | |
158 | |
159 set(DCMTK_PACKAGE_VERSION_SUFFIX "") | |
160 set(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_VERSION_NUMBER}) | |
161 | |
162 | |
163 # For the dcmtls module, necessary since DCMTK 3.6.7 (cf. file | |
164 # "dcmtls/libsrc/tlslayer.cc"). This must be done before the | |
165 # invokation of "configure_file()"! | |
5071
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
166 if (STATIC_BUILD OR NOT USE_SYSTEM_OPENSSL) |
5072
b23a4bb18065
replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5071
diff
changeset
|
167 # The "CHECK_FUNCTIONWITHHEADER_EXISTS()" provided by DCMTK only |
b23a4bb18065
replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5071
diff
changeset
|
168 # works with the system-wide version of OpenSSL. If statically |
b23a4bb18065
replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5071
diff
changeset
|
169 # linking against OpenSSL, we manually provide information about |
b23a4bb18065
replaced bzero() by memset()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5071
diff
changeset
|
170 # OpenSSL 3.0.x |
5071
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
171 set(HAVE_OPENSSL_PROTOTYPE_DH_BITS 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
172 set(HAVE_OPENSSL_PROTOTYPE_EVP_PKEY_BASE_ID 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
173 set(HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET0_PARAM 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
174 set(HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CERT_STORE 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
175 set(HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CIPHERS 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
176 set(HAVE_OPENSSL_PROTOTYPE_X509_GET_SIGNATURE_NID 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
177 set(HAVE_OPENSSL_PROTOTYPE_X509_STORE_GET0_PARAM 1) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
178 else() |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
179 CHECK_FUNCTIONWITHHEADER_EXISTS("DH_bits" "openssl/dh.h" HAVE_OPENSSL_PROTOTYPE_DH_BITS) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
180 CHECK_FUNCTIONWITHHEADER_EXISTS("EVP_PKEY_base_id" "openssl/evp.h" HAVE_OPENSSL_PROTOTYPE_EVP_PKEY_BASE_ID) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
181 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get0_param" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET0_PARAM) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
182 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get_cert_store" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CERT_STORE) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
183 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get_ciphers" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CIPHERS) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
184 CHECK_FUNCTIONWITHHEADER_EXISTS("X509_STORE_get0_param" "openssl/x509.h" HAVE_OPENSSL_PROTOTYPE_X509_STORE_GET0_PARAM) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
185 CHECK_FUNCTIONWITHHEADER_EXISTS("X509_get_signature_nid" "openssl/x509.h" HAVE_OPENSSL_PROTOTYPE_X509_GET_SIGNATURE_NID) |
8fbe84997e23
another try to fix
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5069
diff
changeset
|
186 endif() |
5067 | 187 |
188 | |
189 CONFIGURE_FILE( | |
190 ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in | |
191 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h) | |
192 | |
193 | |
194 | |
195 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
196 link_libraries(netapi32) # For NetWkstaUserGetInfo@12 | |
197 link_libraries(iphlpapi) # For GetAdaptersInfo@8 | |
198 | |
199 # Configure Wine if cross-compiling for Windows | |
200 if (CMAKE_COMPILER_IS_GNUCXX) | |
201 include(${DCMTK_SOURCES_DIR}/CMake/dcmtkUseWine.cmake) | |
202 FIND_PROGRAM(WINE_WINE_PROGRAM wine) | |
203 FIND_PROGRAM(WINE_WINEPATH_PROGRAM winepath) | |
204 list(APPEND DCMTK_TRY_COMPILE_REQUIRED_CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=-static") | |
205 endif() | |
206 endif() | |
207 | |
208 # This step must be after the generation of "osconfig.h" | |
209 if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | |
210 INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES() | |
211 endif() | |
212 | |
213 | |
214 # Source for the logging facility of DCMTK | |
215 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES) | |
216 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR | |
217 ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR | |
218 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR | |
219 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR | |
220 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR | |
221 ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") | |
222 list(REMOVE_ITEM DCMTK_SOURCES | |
223 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc | |
224 ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc | |
225 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc | |
226 ) | |
227 | |
228 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
229 list(REMOVE_ITEM DCMTK_SOURCES | |
230 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc | |
231 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc | |
232 ) | |
233 endif() | |
234 | |
235 | |
236 # Starting with DCMTK 3.6.2, the Nagle algorithm is not disabled by | |
237 # default since this does not seem to be appropriate (anymore) for | |
238 # most modern operating systems. In order to change this default, the | |
239 # environment variable NO_TCPDELAY can be set to "1" (see envvars.txt | |
240 # for details). Alternatively, the macro DISABLE_NAGLE_ALGORITHM can | |
241 # be defined to change this setting at compilation time (see | |
242 # macros.txt for details). | |
243 # https://forum.dcmtk.org/viewtopic.php?t=4632 | |
244 add_definitions( | |
245 -DDISABLE_NAGLE_ALGORITHM=1 | |
246 ) | |
247 | |
248 | |
249 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | |
250 # For compatibility with Windows XP, avoid using fiber-local-storage | |
251 # in log4cplus, but use thread-local-storage instead. Otherwise, | |
252 # Windows XP complains about missing "FlsGetValue()" in KERNEL32.dll | |
253 add_definitions( | |
254 -DDCMTK_LOG4CPLUS_AVOID_WIN32_FLS | |
255 ) | |
256 | |
257 if (CMAKE_COMPILER_IS_GNUCXX OR # MinGW | |
258 "${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") # MSVC for 32bit (*) | |
259 | |
260 # (*) With multithreaded logging enabled, Visual Studio 2008 fails | |
261 # with error: ".\dcmtk-3.6.7\oflog\libsrc\globinit.cc(422) : error | |
262 # C2664: 'dcmtk::log4cplus::thread::impl::tls_init' : cannot | |
263 # convert parameter 1 from 'void (__stdcall *)(void *)' to | |
264 # 'dcmtk::log4cplus::thread::impl::tls_init_cleanup_func_type'" | |
265 # None of the functions with this name in scope match the target type | |
266 | |
267 add_definitions( | |
268 -DDCMTK_LOG4CPLUS_SINGLE_THREADED | |
269 ) | |
270 endif() | |
271 endif() |