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