5067
|
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 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
|
|
67 configure_file(
|
|
68 ${CMAKE_CURRENT_LIST_DIR}/../Patches/dcmtk-dcdict_orthanc.cc
|
|
69 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdict_orthanc.cc
|
|
70 COPYONLY)
|
|
71 else()
|
|
72 message("The patches for DCMTK have already been applied")
|
|
73 endif()
|
|
74
|
|
75
|
|
76 include_directories(
|
|
77 ${DCMTK_SOURCES_DIR}/dcmiod/include
|
|
78 )
|
|
79
|
|
80
|
|
81 # C_CHAR_UNSIGNED *must* be set before calling "GenerateDCMTKConfigure.cmake"
|
|
82 IF (CMAKE_CROSSCOMPILING)
|
|
83 if (CMAKE_COMPILER_IS_GNUCXX AND
|
|
84 CMAKE_SYSTEM_NAME STREQUAL "Windows") # MinGW
|
|
85 SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.")
|
|
86
|
|
87 elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or asm.js
|
|
88
|
|
89 # Check out "../WebAssembly/ArithmeticTests/" to regenerate the
|
|
90 # "arith.h" file
|
|
91 configure_file(
|
|
92 ${CMAKE_CURRENT_LIST_DIR}/WebAssembly/arith.h
|
|
93 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/arith.h
|
|
94 COPYONLY)
|
|
95
|
|
96 UNSET(C_CHAR_UNSIGNED CACHE)
|
|
97 SET(C_CHAR_UNSIGNED 0 CACHE INTERNAL "")
|
|
98
|
|
99 else()
|
|
100 message(FATAL_ERROR "Support your platform here")
|
|
101 endif()
|
|
102 ENDIF()
|
|
103
|
|
104
|
|
105 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
|
|
106 SET(DCMTK_ENABLE_CHARSET_CONVERSION "iconv" CACHE STRING "")
|
|
107 SET(HAVE_SYS_GETTID 0 CACHE INTERNAL "")
|
|
108 endif()
|
|
109
|
|
110
|
|
111 SET(DCMTK_SOURCE_DIR ${DCMTK_SOURCES_DIR})
|
|
112 include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake)
|
|
113 include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake)
|
|
114
|
|
115
|
|
116 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or
|
|
117 # asm.js The macros below are not properly discovered by DCMTK
|
|
118 # when using WebAssembly. Check out "../WebAssembly/arith.h" for
|
|
119 # how we produced these values. This step MUST be after
|
|
120 # "GenerateDCMTKConfigure" and before the generation of
|
|
121 # "osconfig.h".
|
|
122 UNSET(SIZEOF_VOID_P CACHE)
|
|
123 UNSET(SIZEOF_CHAR CACHE)
|
|
124 UNSET(SIZEOF_DOUBLE CACHE)
|
|
125 UNSET(SIZEOF_FLOAT CACHE)
|
|
126 UNSET(SIZEOF_INT CACHE)
|
|
127 UNSET(SIZEOF_LONG CACHE)
|
|
128 UNSET(SIZEOF_SHORT CACHE)
|
|
129 UNSET(SIZEOF_VOID_P CACHE)
|
|
130
|
|
131 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "")
|
|
132 SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
|
|
133 SET(SIZEOF_DOUBLE 8 CACHE INTERNAL "")
|
|
134 SET(SIZEOF_FLOAT 4 CACHE INTERNAL "")
|
|
135 SET(SIZEOF_INT 4 CACHE INTERNAL "")
|
|
136 SET(SIZEOF_LONG 4 CACHE INTERNAL "")
|
|
137 SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
|
|
138 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "")
|
|
139 endif()
|
|
140
|
|
141
|
|
142 set(DCMTK_PACKAGE_VERSION_SUFFIX "")
|
|
143 set(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_VERSION_NUMBER})
|
|
144
|
|
145
|
|
146 # For the dcmtls module, necessary since DCMTK 3.6.7 (cf. file
|
|
147 # "dcmtls/libsrc/tlslayer.cc"). This must be done before the
|
|
148 # invokation of "configure_file()"!
|
|
149 CHECK_FUNCTIONWITHHEADER_EXISTS("DH_bits" "openssl/dh.h" HAVE_OPENSSL_PROTOTYPE_DH_BITS)
|
5069
|
150 CHECK_FUNCTIONWITHHEADER_EXISTS("EVP_PKEY_RSA_PSS" "openssl/evp.h" HAVE_OPENSSL_PROTOTYPE_EVP_PKEY_RSA_PSS)
|
5067
|
151 CHECK_FUNCTIONWITHHEADER_EXISTS("EVP_PKEY_base_id" "openssl/evp.h" HAVE_OPENSSL_PROTOTYPE_EVP_PKEY_BASE_ID)
|
5069
|
152 CHECK_FUNCTIONWITHHEADER_EXISTS("RAND_egd" "openssl/rand.h" HAVE_OPENSSL_PROTOTYPE_RAND_EGD)
|
5067
|
153 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get0_param" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET0_PARAM)
|
|
154 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get_cert_store" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CERT_STORE)
|
|
155 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_get_ciphers" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_GET_CIPHERS)
|
5069
|
156 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set0_tmp_dh_pkey" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET0_TMP_DH_PKEY)
|
|
157 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set1_curves(0,0,0)" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET1_CURVES)
|
|
158 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set1_sigalgs" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET1_SIGALGS)
|
|
159 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set_ecdh_auto(0,0)" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET_ECDH_AUTO)
|
|
160 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set_max_proto_version(0,0)" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET_MAX_PROTO_VERSION)
|
|
161 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_CTX_set_security_level" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_CTX_SET_SECURITY_LEVEL)
|
|
162 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_ERROR_WANT_ASYNC" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_ERROR_WANT_ASYNC)
|
|
163 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_ERROR_WANT_ASYNC_JOB" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_ERROR_WANT_ASYNC_JOB)
|
|
164 CHECK_FUNCTIONWITHHEADER_EXISTS("SSL_ERROR_WANT_CLIENT_HELLO_CB" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_SSL_ERROR_WANT_CLIENT_HELLO_CB)
|
|
165 CHECK_FUNCTIONWITHHEADER_EXISTS("TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305)
|
|
166 CHECK_FUNCTIONWITHHEADER_EXISTS("TLS_method" "openssl/ssl.h" HAVE_OPENSSL_PROTOTYPE_TLS_METHOD)
|
5067
|
167 CHECK_FUNCTIONWITHHEADER_EXISTS("X509_STORE_get0_param" "openssl/x509.h" HAVE_OPENSSL_PROTOTYPE_X509_STORE_GET0_PARAM)
|
|
168 CHECK_FUNCTIONWITHHEADER_EXISTS("X509_get_signature_nid" "openssl/x509.h" HAVE_OPENSSL_PROTOTYPE_X509_GET_SIGNATURE_NID)
|
|
169
|
|
170
|
|
171 CONFIGURE_FILE(
|
|
172 ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in
|
|
173 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h)
|
|
174
|
|
175
|
|
176
|
|
177 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
178 link_libraries(netapi32) # For NetWkstaUserGetInfo@12
|
|
179 link_libraries(iphlpapi) # For GetAdaptersInfo@8
|
|
180
|
|
181 # Configure Wine if cross-compiling for Windows
|
|
182 if (CMAKE_COMPILER_IS_GNUCXX)
|
|
183 include(${DCMTK_SOURCES_DIR}/CMake/dcmtkUseWine.cmake)
|
|
184 FIND_PROGRAM(WINE_WINE_PROGRAM wine)
|
|
185 FIND_PROGRAM(WINE_WINEPATH_PROGRAM winepath)
|
|
186 list(APPEND DCMTK_TRY_COMPILE_REQUIRED_CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=-static")
|
|
187 endif()
|
|
188 endif()
|
|
189
|
|
190 # This step must be after the generation of "osconfig.h"
|
|
191 if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
|
|
192 INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES()
|
|
193 endif()
|
|
194
|
|
195
|
|
196 # Source for the logging facility of DCMTK
|
|
197 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES)
|
|
198 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
|
|
199 ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
|
|
200 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
|
|
201 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
|
|
202 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR
|
|
203 ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
|
204 list(REMOVE_ITEM DCMTK_SOURCES
|
|
205 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc
|
|
206 ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc
|
|
207 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc
|
|
208 )
|
|
209
|
|
210 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
211 list(REMOVE_ITEM DCMTK_SOURCES
|
|
212 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc
|
|
213 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc
|
|
214 )
|
|
215 endif()
|
|
216
|
|
217
|
|
218 # Starting with DCMTK 3.6.2, the Nagle algorithm is not disabled by
|
|
219 # default since this does not seem to be appropriate (anymore) for
|
|
220 # most modern operating systems. In order to change this default, the
|
|
221 # environment variable NO_TCPDELAY can be set to "1" (see envvars.txt
|
|
222 # for details). Alternatively, the macro DISABLE_NAGLE_ALGORITHM can
|
|
223 # be defined to change this setting at compilation time (see
|
|
224 # macros.txt for details).
|
|
225 # https://forum.dcmtk.org/viewtopic.php?t=4632
|
|
226 add_definitions(
|
|
227 -DDISABLE_NAGLE_ALGORITHM=1
|
|
228 )
|
|
229
|
|
230
|
|
231 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
232 # For compatibility with Windows XP, avoid using fiber-local-storage
|
|
233 # in log4cplus, but use thread-local-storage instead. Otherwise,
|
|
234 # Windows XP complains about missing "FlsGetValue()" in KERNEL32.dll
|
|
235 add_definitions(
|
|
236 -DDCMTK_LOG4CPLUS_AVOID_WIN32_FLS
|
|
237 )
|
|
238
|
|
239 if (CMAKE_COMPILER_IS_GNUCXX OR # MinGW
|
|
240 "${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") # MSVC for 32bit (*)
|
|
241
|
|
242 # (*) With multithreaded logging enabled, Visual Studio 2008 fails
|
|
243 # with error: ".\dcmtk-3.6.7\oflog\libsrc\globinit.cc(422) : error
|
|
244 # C2664: 'dcmtk::log4cplus::thread::impl::tls_init' : cannot
|
|
245 # convert parameter 1 from 'void (__stdcall *)(void *)' to
|
|
246 # 'dcmtk::log4cplus::thread::impl::tls_init_cleanup_func_type'"
|
|
247 # None of the functions with this name in scope match the target type
|
|
248
|
|
249 add_definitions(
|
|
250 -DDCMTK_LOG4CPLUS_SINGLE_THREADED
|
|
251 )
|
|
252 endif()
|
|
253 endif()
|