comparison OrthancFramework/Resources/CMake/DcmtkConfiguration.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/DcmtkConfiguration.cmake@9d2d2c1afcec
children 304842a0d152
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
1 if (NOT DEFINED ENABLE_DCMTK_NETWORKING)
2 set(ENABLE_DCMTK_NETWORKING ON)
3 endif()
4
5 if (STATIC_BUILD OR NOT USE_SYSTEM_DCMTK)
6 if (DCMTK_STATIC_VERSION STREQUAL "3.6.0")
7 include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfigurationStatic-3.6.0.cmake)
8 elseif (DCMTK_STATIC_VERSION STREQUAL "3.6.2")
9 include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfigurationStatic-3.6.2.cmake)
10 elseif (DCMTK_STATIC_VERSION STREQUAL "3.6.4")
11 include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfigurationStatic-3.6.4.cmake)
12 elseif (DCMTK_STATIC_VERSION STREQUAL "3.6.5")
13 include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfigurationStatic-3.6.5.cmake)
14 else()
15 message(FATAL_ERROR "Unsupported version of DCMTK: ${DCMTK_STATIC_VERSION}")
16 endif()
17
18
19 ##
20 ## Commands shared by all versions of DCMTK
21 ##
22
23 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmdata/libsrc DCMTK_SOURCES)
24 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/ofstd/libsrc DCMTK_SOURCES)
25
26 LIST(REMOVE_ITEM DCMTK_SOURCES
27 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc
28 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc
29 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdict_orthanc.cc
30 )
31
32 if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
33 message(${DCMTK_SOURCES_DIR})
34 list(REMOVE_ITEM DCMTK_SOURCES
35 ${DCMTK_SOURCES_DIR}/ofstd/libsrc/offilsys.cc
36 )
37 endif()
38
39 if (ENABLE_DCMTK_NETWORKING)
40 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmnet/libsrc DCMTK_SOURCES)
41 include_directories(
42 ${DCMTK_SOURCES_DIR}/dcmnet/include
43 )
44 endif()
45
46 if (ENABLE_DCMTK_TRANSCODING)
47 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmimgle/libsrc DCMTK_SOURCES)
48 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmimage/libsrc DCMTK_SOURCES)
49 include_directories(
50 ${DCMTK_SOURCES_DIR}/dcmimage/include
51 )
52 endif()
53
54 if (ENABLE_DCMTK_JPEG)
55 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc DCMTK_SOURCES)
56 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8 DCMTK_SOURCES)
57 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12 DCMTK_SOURCES)
58 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16 DCMTK_SOURCES)
59 include_directories(
60 ${DCMTK_SOURCES_DIR}/dcmjpeg/include
61 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8
62 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12
63 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16
64 ${DCMTK_SOURCES_DIR}/dcmimgle/include
65 )
66 list(REMOVE_ITEM DCMTK_SOURCES
67 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/ddpiimpl.cc
68
69 # Solves linking problem in WebAssembly: "wasm-ld: error:
70 # duplicate symbol: jaritab" (modification in Orthanc 1.5.9)
71 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8/jaricom.c
72 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12/jaricom.c
73 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg24/jaricom.c
74 )
75
76 if (NOT ENABLE_DCMTK_TRANSCODING)
77 list(REMOVE_ITEM DCMTK_SOURCES
78 # Disable support for encoding JPEG (modification in Orthanc 1.0.1)
79 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djcodece.cc
80 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencsv1.cc
81 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencbas.cc
82 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencpro.cc
83 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djenclol.cc
84 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencode.cc
85 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencext.cc
86 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djencsps.cc
87 )
88 endif()
89 endif()
90
91
92 if (ENABLE_DCMTK_JPEG_LOSSLESS)
93 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libsrc DCMTK_SOURCES)
94 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libcharls DCMTK_SOURCES)
95 include_directories(
96 ${DCMTK_SOURCES_DIR}/dcmjpeg/include
97 ${DCMTK_SOURCES_DIR}/dcmjpls/include
98 ${DCMTK_SOURCES_DIR}/dcmjpls/libcharls
99 )
100 list(APPEND DCMTK_SOURCES
101 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djrplol.cc
102 )
103
104 if (NOT ENABLE_DCMTK_TRANSCODING)
105 list(REMOVE_ITEM DCMTK_SOURCES
106 ${DCMTK_SOURCES_DIR}/dcmjpls/libsrc/djcodece.cc
107
108 # Disable support for encoding JPEG-LS (modification in Orthanc 1.0.1)
109 ${DCMTK_SOURCES_DIR}/dcmjpls/libsrc/djencode.cc
110 )
111 endif()
112 endif()
113
114
115 # This fixes crashes related to the destruction of the DCMTK OFLogger
116 # http://support.dcmtk.org/docs-snapshot/file_macros.html
117 add_definitions(
118 -DLOG4CPLUS_DISABLE_FATAL=1
119 -DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER}
120 )
121
122
123 if (NOT ENABLE_DCMTK_LOG)
124 # Disable logging internal to DCMTK
125 # https://groups.google.com/d/msg/orthanc-users/v2SzzAmY948/VxT1QVGiBAAJ
126 add_definitions(
127 -DDCMTK_LOG4CPLUS_DISABLE_FATAL=1
128 -DDCMTK_LOG4CPLUS_DISABLE_ERROR=1
129 -DDCMTK_LOG4CPLUS_DISABLE_WARN=1
130 -DDCMTK_LOG4CPLUS_DISABLE_INFO=1
131 -DDCMTK_LOG4CPLUS_DISABLE_DEBUG=1
132 )
133 endif()
134
135 include_directories(
136 #${DCMTK_SOURCES_DIR}
137 ${DCMTK_SOURCES_DIR}/config/include
138 ${DCMTK_SOURCES_DIR}/ofstd/include
139 ${DCMTK_SOURCES_DIR}/oflog/include
140 ${DCMTK_SOURCES_DIR}/dcmdata/include
141 )
142
143 source_group(ThirdParty\\Dcmtk REGULAR_EXPRESSION ${DCMTK_SOURCES_DIR}/.*)
144
145 if (STANDALONE_BUILD)
146 set(DCMTK_USE_EMBEDDED_DICTIONARIES 1)
147 set(DCMTK_DICTIONARIES
148 DICTIONARY_DICOM ${DCMTK_SOURCES_DIR}/dcmdata/data/dicom.dic
149 DICTIONARY_PRIVATE ${DCMTK_SOURCES_DIR}/dcmdata/data/private.dic
150 DICTIONARY_DICONDE ${DCMTK_SOURCES_DIR}/dcmdata/data/diconde.dic
151 )
152 else()
153 set(DCMTK_USE_EMBEDDED_DICTIONARIES 0)
154 endif()
155
156
157 else()
158 if (CMAKE_CROSSCOMPILING AND
159 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg")
160
161 CHECK_INCLUDE_FILE_CXX(dcmtk/dcmdata/dcfilefo.h HAVE_DCMTK_H)
162 if (NOT HAVE_DCMTK_H)
163 message(FATAL_ERROR "Please install the libdcmtk-dev package")
164 endif()
165
166 CHECK_LIBRARY_EXISTS(dcmdata "dcmDataDict" "" HAVE_DCMTK_LIB)
167 if (NOT HAVE_DCMTK_LIB)
168 message(FATAL_ERROR "Please install the libdcmtk package")
169 endif()
170
171 find_path(DCMTK_INCLUDE_DIRS dcmtk/config/osconfig.h
172 /usr/include
173 )
174
175 link_libraries(dcmdata dcmnet dcmjpeg oflog ofstd)
176
177 else()
178 # The following line allows one to manually add libraries at the
179 # command-line, which is necessary for Ubuntu/Debian packages
180 set(tmp "${DCMTK_LIBRARIES}")
181 include(FindDCMTK)
182 list(APPEND DCMTK_LIBRARIES "${tmp}")
183
184 include_directories(${DCMTK_INCLUDE_DIRS})
185 endif()
186
187 add_definitions(
188 -DHAVE_CONFIG_H=1
189 )
190
191 if (EXISTS "${DCMTK_config_INCLUDE_DIR}/cfunix.h")
192 set(DCMTK_CONFIGURATION_FILE "${DCMTK_config_INCLUDE_DIR}/cfunix.h")
193 elseif (EXISTS "${DCMTK_config_INCLUDE_DIR}/osconfig.h") # This is for Arch Linux
194 set(DCMTK_CONFIGURATION_FILE "${DCMTK_config_INCLUDE_DIR}/osconfig.h")
195 elseif (EXISTS "${DCMTK_INCLUDE_DIRS}/dcmtk/config/osconfig.h") # This is for Debian Buster
196 set(DCMTK_CONFIGURATION_FILE "${DCMTK_INCLUDE_DIRS}/dcmtk/config/osconfig.h")
197 else()
198 message(FATAL_ERROR "Please install libdcmtk*-dev")
199 endif()
200
201 message("DCMTK configuration file: ${DCMTK_CONFIGURATION_FILE}")
202
203 # Autodetection of the version of DCMTK
204 file(STRINGS
205 "${DCMTK_CONFIGURATION_FILE}"
206 DCMTK_VERSION_NUMBER1 REGEX
207 ".*PACKAGE_VERSION .*")
208
209 string(REGEX REPLACE
210 ".*PACKAGE_VERSION.*\"([0-9]*)\\.([0-9]*)\\.([0-9]*)\"$"
211 "\\1\\2\\3"
212 DCMTK_VERSION_NUMBER
213 ${DCMTK_VERSION_NUMBER1})
214
215 set(DCMTK_USE_EMBEDDED_DICTIONARIES 0)
216 endif()
217
218
219 add_definitions(-DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER})
220 message("DCMTK version: ${DCMTK_VERSION_NUMBER}")
221
222
223 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=${DCMTK_USE_EMBEDDED_DICTIONARIES})
224 if (NOT DCMTK_USE_EMBEDDED_DICTIONARIES)
225 # Lookup for DICOM dictionaries, if none is specified by the user
226 if (DCMTK_DICTIONARY_DIR STREQUAL "")
227 find_path(DCMTK_DICTIONARY_DIR_AUTO dicom.dic
228 /usr/share/dcmtk
229 /usr/share/libdcmtk1
230 /usr/share/libdcmtk2
231 /usr/share/libdcmtk3
232 /usr/share/libdcmtk4
233 /usr/share/libdcmtk5
234 /usr/share/libdcmtk6
235 /usr/share/libdcmtk7
236 /usr/share/libdcmtk8
237 /usr/share/libdcmtk9
238 /usr/share/libdcmtk10
239 /usr/share/libdcmtk11
240 /usr/share/libdcmtk12
241 /usr/share/libdcmtk13
242 /usr/share/libdcmtk14
243 /usr/share/libdcmtk15
244 /usr/share/libdcmtk16
245 /usr/share/libdcmtk17
246 /usr/share/libdcmtk18
247 /usr/share/libdcmtk19
248 /usr/share/libdcmtk20
249 /usr/local/share/dcmtk
250 )
251
252 if (${DCMTK_DICTIONARY_DIR_AUTO} MATCHES "DCMTK_DICTIONARY_DIR_AUTO-NOTFOUND")
253 message(FATAL_ERROR "Cannot locate the DICOM dictionary on this system")
254 endif()
255
256 if (CMAKE_CROSSCOMPILING AND
257 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg")
258 # Remove the sysroot prefix
259 file(RELATIVE_PATH tmp ${CMAKE_FIND_ROOT_PATH} ${DCMTK_DICTIONARY_DIR_AUTO})
260 set(DCMTK_DICTIONARY_DIR_AUTO /${tmp} CACHE INTERNAL "")
261 endif()
262
263 message("Autodetected path to the DICOM dictionaries: ${DCMTK_DICTIONARY_DIR_AUTO}")
264 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR_AUTO}")
265 else()
266 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR}")
267 endif()
268 endif()