Mercurial > hg > orthanc
annotate Resources/CMake/DcmtkConfiguration.cmake @ 1769:cb466194f22c
fail if no DICOM dictionary
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Nov 2015 16:37:01 +0100 |
parents | 8c4f1de71f8d |
children | 6473e4e22d44 |
rev | line source |
---|---|
929 | 1 # Lookup for DICOM dictionaries, if none is specified by the user |
2 if (DCMTK_DICTIONARY_DIR STREQUAL "") | |
3 find_path(DCMTK_DICTIONARY_DIR_AUTO dicom.dic | |
4 /usr/share/dcmtk | |
5 /usr/share/libdcmtk2 | |
1769
cb466194f22c
fail if no DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1636
diff
changeset
|
6 /usr/share/libdcmtk4 |
1334 | 7 /usr/local/share/dcmtk |
929 | 8 ) |
9 | |
1769
cb466194f22c
fail if no DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1636
diff
changeset
|
10 if (${DCMTK_DICTIONARY_DIR_AUTO} MATCHES "DCMTK_DICTIONARY_DIR_AUTO-NOTFOUND") |
cb466194f22c
fail if no DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1636
diff
changeset
|
11 message(FATAL_ERROR "Cannot locate the DICOM dictionary on this system") |
cb466194f22c
fail if no DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1636
diff
changeset
|
12 endif() |
cb466194f22c
fail if no DICOM dictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1636
diff
changeset
|
13 |
929 | 14 message("Autodetected path to the DICOM dictionaries: ${DCMTK_DICTIONARY_DIR_AUTO}") |
15 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR_AUTO}") | |
16 else() | |
17 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR}") | |
18 endif() | |
19 | |
20 | |
21 if (STATIC_BUILD OR NOT USE_SYSTEM_DCMTK) | |
22 SET(DCMTK_VERSION_NUMBER 360) | |
1634 | 23 set(DCMTK_PACKAGE_VERSION "3.6.0") |
929 | 24 SET(DCMTK_SOURCES_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.0) |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
25 SET(DCMTK_URL "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/dcmtk-3.6.0.zip") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
26 SET(DCMTK_MD5 "219ad631b82031806147e4abbfba4fa4") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
27 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
28 if (IS_DIRECTORY "${DCMTK_SOURCES_DIR}") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
29 set(FirstRun OFF) |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
30 else() |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
31 set(FirstRun ON) |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
32 endif() |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
33 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
34 DownloadPackage(${DCMTK_MD5} ${DCMTK_URL} "${DCMTK_SOURCES_DIR}") |
929 | 35 |
1414 | 36 IF (CMAKE_CROSSCOMPILING) |
929 | 37 SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.") |
38 ENDIF() | |
1634 | 39 SET(DCMTK_SOURCE_DIR ${DCMTK_SOURCES_DIR}) |
929 | 40 include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake) |
41 include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake) | |
42 | |
43 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | |
44 set(HAVE_SSTREAM 1) | |
45 set(HAVE_PROTOTYPE_BZERO 1) | |
46 set(HAVE_PROTOTYPE_GETHOSTNAME 1) | |
47 set(HAVE_PROTOTYPE_GETSOCKOPT 1) | |
48 set(HAVE_PROTOTYPE_SETSOCKOPT 1) | |
49 set(HAVE_PROTOTYPE_CONNECT 1) | |
50 set(HAVE_PROTOTYPE_BIND 1) | |
51 set(HAVE_PROTOTYPE_ACCEPT 1) | |
52 set(HAVE_PROTOTYPE_SETSOCKNAME 1) | |
53 set(HAVE_PROTOTYPE_GETSOCKNAME 1) | |
54 endif() | |
55 | |
1149
dd6d7fd82da9
fix version of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1057
diff
changeset
|
56 set(DCMTK_PACKAGE_VERSION_SUFFIX "") |
1634 | 57 set(DCMTK_PACKAGE_VERSION_NUMBER ${DCMTK_VERSION_NUMBER}) |
1149
dd6d7fd82da9
fix version of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1057
diff
changeset
|
58 |
929 | 59 CONFIGURE_FILE( |
60 ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in | |
61 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h) | |
62 | |
63 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmnet/libsrc DCMTK_SOURCES) | |
64 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmdata/libsrc DCMTK_SOURCES) | |
65 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/ofstd/libsrc DCMTK_SOURCES) | |
66 | |
67 | |
68 if (ENABLE_JPEG) | |
69 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc DCMTK_SOURCES) | |
70 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8 DCMTK_SOURCES) | |
71 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12 DCMTK_SOURCES) | |
72 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16 DCMTK_SOURCES) | |
73 include_directories( | |
74 ${DCMTK_SOURCES_DIR}/dcmjpeg/include | |
75 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8 | |
76 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12 | |
77 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16 | |
78 ${DCMTK_SOURCES_DIR}/dcmimgle/include | |
79 ) | |
80 list(REMOVE_ITEM DCMTK_SOURCES | |
81 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/ddpiimpl.cc | |
82 ) | |
83 endif() | |
84 | |
85 | |
86 if (ENABLE_JPEG_LOSSLESS) | |
87 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libsrc DCMTK_SOURCES) | |
88 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libcharls DCMTK_SOURCES) | |
89 include_directories( | |
90 ${DCMTK_SOURCES_DIR}/dcmjpeg/include | |
91 ${DCMTK_SOURCES_DIR}/dcmjpls/include | |
92 ${DCMTK_SOURCES_DIR}/dcmjpls/libcharls | |
93 ) | |
94 list(REMOVE_ITEM DCMTK_SOURCES | |
95 ${DCMTK_SOURCES_DIR}/dcmjpls/libsrc/djcodece.cc | |
96 ) | |
97 list(APPEND DCMTK_SOURCES | |
98 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djrplol.cc | |
99 ) | |
100 endif() | |
101 | |
102 | |
103 # Source for the logging facility of DCMTK | |
104 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES) | |
105 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR | |
930 | 106 ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR |
1337 | 107 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR |
929 | 108 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") |
109 list(REMOVE_ITEM DCMTK_SOURCES | |
110 ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc | |
111 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc | |
112 ) | |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
113 |
1362
bf6db7d2f8b1
fix slow DCMTK problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
114 execute_process( |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
115 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${ORTHANC_ROOT}/Resources/Patches/dcmtk-linux-speed.patch |
1362
bf6db7d2f8b1
fix slow DCMTK problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
116 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
117 RESULT_VARIABLE Failure |
1362
bf6db7d2f8b1
fix slow DCMTK problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
118 ) |
bf6db7d2f8b1
fix slow DCMTK problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
119 |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
120 if (Failure AND FirstRun) |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
121 message(FATAL_ERROR "Error while patching a file") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
122 endif() |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
123 |
929 | 124 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
125 list(REMOVE_ITEM DCMTK_SOURCES | |
126 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc | |
127 ) | |
128 | |
1415 | 129 if (CMAKE_COMPILER_IS_GNUCXX) |
929 | 130 # This is a patch for MinGW64 |
131 execute_process( | |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
132 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${ORTHANC_ROOT}/Resources/Patches/dcmtk-mingw64.patch |
929 | 133 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
134 RESULT_VARIABLE Failure |
929 | 135 ) |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
136 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
137 if (Failure AND FirstRun) |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
138 message(FATAL_ERROR "Error while patching a file") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
139 endif() |
929 | 140 endif() |
141 | |
1377
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1362
diff
changeset
|
142 # This patch improves speed, even for Windows |
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1362
diff
changeset
|
143 execute_process( |
1546 | 144 COMMAND ${PATCH_EXECUTABLE} -p0 -N |
145 INPUT_FILE ${ORTHANC_ROOT}/Resources/Patches/dcmtk-linux-speed.patch | |
1377
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1362
diff
changeset
|
146 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
147 RESULT_VARIABLE Failure |
1377
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1362
diff
changeset
|
148 ) |
601d34afdab9
patch for recent versions of MinGW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1362
diff
changeset
|
149 |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
150 if (Failure AND FirstRun) |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
151 message(FATAL_ERROR "Error while patching a file") |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1415
diff
changeset
|
152 endif() |
929 | 153 endif() |
154 | |
155 list(REMOVE_ITEM DCMTK_SOURCES | |
156 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc | |
157 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc | |
158 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdictbi.cc | |
159 ) | |
160 | |
1149
dd6d7fd82da9
fix version of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1057
diff
changeset
|
161 #set_source_files_properties(${DCMTK_SOURCES} |
dd6d7fd82da9
fix version of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1057
diff
changeset
|
162 # PROPERTIES COMPILE_DEFINITIONS |
1636 | 163 # "PACKAGE_VERSION=\"${DCMTK_PACKAGE_VERSION}\";PACKAGE_VERSION_NUMBER=\"${DCMTK_VERSION_NUMBER}\"") |
1149
dd6d7fd82da9
fix version of dcmtk
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1057
diff
changeset
|
164 |
929 | 165 # This fixes crashes related to the destruction of the DCMTK OFLogger |
166 # http://support.dcmtk.org/docs-snapshot/file_macros.html | |
167 add_definitions( | |
168 -DLOG4CPLUS_DISABLE_FATAL=1 | |
1634 | 169 -DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER} |
929 | 170 ) |
171 | |
172 include_directories( | |
173 #${DCMTK_SOURCES_DIR} | |
174 ${DCMTK_SOURCES_DIR}/config/include | |
175 ${DCMTK_SOURCES_DIR}/dcmnet/include | |
176 ${DCMTK_SOURCES_DIR}/ofstd/include | |
177 ${DCMTK_SOURCES_DIR}/oflog/include | |
178 ${DCMTK_SOURCES_DIR}/dcmdata/include | |
179 ) | |
180 | |
181 source_group(ThirdParty\\Dcmtk REGULAR_EXPRESSION ${DCMTK_SOURCES_DIR}/.*) | |
182 | |
183 set(DCMTK_BUNDLES_LOG4CPLUS 1) | |
184 | |
185 if (STANDALONE_BUILD) | |
186 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=1) | |
187 else() | |
188 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0) | |
189 endif() | |
190 | |
191 set(DCMTK_DICTIONARIES | |
192 DICTIONARY_DICOM ${DCMTK_SOURCES_DIR}/dcmdata/data/dicom.dic | |
193 DICTIONARY_PRIVATE ${DCMTK_SOURCES_DIR}/dcmdata/data/private.dic | |
194 DICTIONARY_DICONDE ${DCMTK_SOURCES_DIR}/dcmdata/data/diconde.dic | |
195 ) | |
196 | |
197 else() | |
198 # The following line allows to manually add libraries at the | |
199 # command-line, which is necessary for Ubuntu/Debian packages | |
200 set(tmp "${DCMTK_LIBRARIES}") | |
201 include(FindDCMTK) | |
202 list(APPEND DCMTK_LIBRARIES "${tmp}") | |
203 | |
204 include_directories(${DCMTK_INCLUDE_DIR}) | |
205 | |
206 add_definitions( | |
207 -DHAVE_CONFIG_H=1 | |
208 ) | |
209 | |
210 if (EXISTS "${DCMTK_DIR}/config/cfunix.h") | |
211 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/cfunix.h") | |
212 elseif (EXISTS "${DCMTK_DIR}/config/osconfig.h") # This is for Arch Linux | |
213 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/osconfig.h") | |
214 else() | |
215 message(FATAL_ERROR "Please install libdcmtk1-dev") | |
216 endif() | |
217 | |
218 # Autodetection of the version of DCMTK | |
219 file(STRINGS | |
220 "${DCMTK_CONFIGURATION_FILE}" | |
221 DCMTK_VERSION_NUMBER1 REGEX | |
222 ".*PACKAGE_VERSION .*") | |
223 | |
224 string(REGEX REPLACE | |
225 ".*PACKAGE_VERSION.*\"([0-9]*)\\.([0-9]*)\\.([0-9]*)\"$" | |
226 "\\1\\2\\3" | |
227 DCMTK_VERSION_NUMBER | |
228 ${DCMTK_VERSION_NUMBER1}) | |
229 | |
230 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0) | |
231 | |
232 endif() | |
233 | |
234 add_definitions(-DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER}) | |
235 message("DCMTK version: ${DCMTK_VERSION_NUMBER}") |