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