comparison OrthancFramework/Resources/CMake/DcmtkConfigurationStatic-3.6.5.cmake @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/CMake/DcmtkConfigurationStatic-3.6.5.cmake@05a363186da6
children 05b8fd21089c
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 SET(DCMTK_VERSION_NUMBER 365)
2 SET(DCMTK_PACKAGE_VERSION "3.6.5")
3 SET(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.5)
4 SET(DCMTK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/dcmtk-3.6.5.tar.gz")
5 SET(DCMTK_MD5 "e19707f64ee5695c496b9c1e48e39d07")
6
7 macro(DCMTK_UNSET)
8 endmacro()
9
10 macro(DCMTK_UNSET_CACHE)
11 endmacro()
12
13 set(DCMTK_BINARY_DIR ${DCMTK_SOURCES_DIR}/)
14 set(DCMTK_CMAKE_INCLUDE ${DCMTK_SOURCES_DIR}/)
15
16 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
17 set(DCMTK_WITH_THREADS OFF) # Disable thread support in wasm/asm.js
18 else()
19 set(DCMTK_WITH_THREADS ON)
20 endif()
21
22 add_definitions(-DDCMTK_INSIDE_LOG4CPLUS=1)
23
24 if (IS_DIRECTORY "${DCMTK_SOURCES_DIR}")
25 set(FirstRun OFF)
26 else()
27 set(FirstRun ON)
28 endif()
29
30 DownloadPackage(${DCMTK_MD5} ${DCMTK_URL} "${DCMTK_SOURCES_DIR}")
31
32
33 if (FirstRun)
34 # Apply the patches
35 execute_process(
36 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i
37 ${ORTHANC_ROOT}/Resources/Patches/dcmtk-3.6.5.patch
38 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
39 RESULT_VARIABLE Failure
40 )
41
42 if (Failure)
43 message(FATAL_ERROR "Error while patching a file")
44 endif()
45
46 configure_file(
47 ${ORTHANC_ROOT}/Resources/Patches/dcmtk-dcdict_orthanc.cc
48 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdict_orthanc.cc
49 COPYONLY)
50 else()
51 message("The patches for DCMTK have already been applied")
52 endif()
53
54
55 include_directories(
56 ${DCMTK_SOURCES_DIR}/dcmiod/include
57 )
58
59
60 # C_CHAR_UNSIGNED *must* be set before calling "GenerateDCMTKConfigure.cmake"
61 IF (CMAKE_CROSSCOMPILING)
62 if (CMAKE_COMPILER_IS_GNUCXX AND
63 CMAKE_SYSTEM_NAME STREQUAL "Windows") # MinGW
64 SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.")
65
66 elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or asm.js
67
68 # Check out "../WebAssembly/ArithmeticTests/" to regenerate the
69 # "arith.h" file
70 configure_file(
71 ${ORTHANC_ROOT}/Resources/WebAssembly/arith.h
72 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/arith.h
73 COPYONLY)
74
75 UNSET(C_CHAR_UNSIGNED CACHE)
76 SET(C_CHAR_UNSIGNED 0 CACHE INTERNAL "")
77
78 else()
79 message(FATAL_ERROR "Support your platform here")
80 endif()
81 ENDIF()
82
83
84 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
85 SET(DCMTK_ENABLE_CHARSET_CONVERSION "iconv" CACHE STRING "")
86 SET(HAVE_SYS_GETTID 0 CACHE INTERNAL "")
87 endif()
88
89
90 SET(DCMTK_SOURCE_DIR ${DCMTK_SOURCES_DIR})
91 include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake)
92 include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake)
93
94
95 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # WebAssembly or
96 # asm.js The macros below are not properly discovered by DCMTK
97 # when using WebAssembly. Check out "../WebAssembly/arith.h" for
98 # how we produced these values. This step MUST be after
99 # "GenerateDCMTKConfigure" and before the generation of
100 # "osconfig.h".
101 UNSET(SIZEOF_VOID_P CACHE)
102 UNSET(SIZEOF_CHAR CACHE)
103 UNSET(SIZEOF_DOUBLE CACHE)
104 UNSET(SIZEOF_FLOAT CACHE)
105 UNSET(SIZEOF_INT CACHE)
106 UNSET(SIZEOF_LONG CACHE)
107 UNSET(SIZEOF_SHORT CACHE)
108 UNSET(SIZEOF_VOID_P CACHE)
109
110 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "")
111 SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
112 SET(SIZEOF_DOUBLE 8 CACHE INTERNAL "")
113 SET(SIZEOF_FLOAT 4 CACHE INTERNAL "")
114 SET(SIZEOF_INT 4 CACHE INTERNAL "")
115 SET(SIZEOF_LONG 4 CACHE INTERNAL "")
116 SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
117 SET(SIZEOF_VOID_P 4 CACHE INTERNAL "")
118 endif()
119
120
121 set(DCMTK_PACKAGE_VERSION_SUFFIX "")
122 set(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_VERSION_NUMBER})
123
124 CONFIGURE_FILE(
125 ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in
126 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h)
127
128 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
129 link_libraries(netapi32) # For NetWkstaUserGetInfo@12
130 link_libraries(iphlpapi) # For GetAdaptersInfo@8
131
132 # Configure Wine if cross-compiling for Windows
133 if (CMAKE_COMPILER_IS_GNUCXX)
134 include(${DCMTK_SOURCES_DIR}/CMake/dcmtkUseWine.cmake)
135 FIND_PROGRAM(WINE_WINE_PROGRAM wine)
136 FIND_PROGRAM(WINE_WINEPATH_PROGRAM winepath)
137 list(APPEND DCMTK_TRY_COMPILE_REQUIRED_CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=-static")
138 endif()
139 endif()
140
141 # This step must be after the generation of "osconfig.h"
142 if (NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
143 INSPECT_FUNDAMENTAL_ARITHMETIC_TYPES()
144 endif()
145
146
147 # Source for the logging facility of DCMTK
148 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES)
149 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
150 ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
151 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
152 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
153 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" OR
154 ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
155 list(REMOVE_ITEM DCMTK_SOURCES
156 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc
157 ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc
158 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc
159 )
160
161 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
162 list(REMOVE_ITEM DCMTK_SOURCES
163 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc
164 ${DCMTK_SOURCES_DIR}/oflog/libsrc/clfsap.cc
165 )
166 endif()
167
168
169 # Starting with DCMTK 3.6.2, the Nagle algorithm is not disabled by
170 # default since this does not seem to be appropriate (anymore) for
171 # most modern operating systems. In order to change this default, the
172 # environment variable NO_TCPDELAY can be set to "1" (see envvars.txt
173 # for details). Alternatively, the macro DISABLE_NAGLE_ALGORITHM can
174 # be defined to change this setting at compilation time (see
175 # macros.txt for details).
176 # https://forum.dcmtk.org/viewtopic.php?t=4632
177 add_definitions(
178 -DDISABLE_NAGLE_ALGORITHM=1
179 )
180
181
182 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
183 # For compatibility with Windows XP, avoid using fiber-local-storage
184 # in log4cplus, but use thread-local-storage instead. Otherwise,
185 # Windows XP complains about missing "FlsGetValue()" in KERNEL32.dll
186 add_definitions(
187 -DDCMTK_LOG4CPLUS_AVOID_WIN32_FLS
188 )
189
190 if (CMAKE_COMPILER_IS_GNUCXX OR # MinGW
191 "${CMAKE_SIZEOF_VOID_P}" STREQUAL "4") # MSVC for 32bit (*)
192
193 # (*) With multithreaded logging enabled, Visual Studio 2008 fails
194 # with error: ".\dcmtk-3.6.5\oflog\libsrc\globinit.cc(422) : error
195 # C2664: 'dcmtk::log4cplus::thread::impl::tls_init' : cannot
196 # convert parameter 1 from 'void (__stdcall *)(void *)' to
197 # 'dcmtk::log4cplus::thread::impl::tls_init_cleanup_func_type'"
198 # None of the functions with this name in scope match the target type
199
200 add_definitions(
201 -DDCMTK_LOG4CPLUS_SINGLE_THREADED
202 )
203 endif()
204 endif()