856
|
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
|
|
6 )
|
|
7
|
|
8 message("Autodetected path to the DICOM dictionaries: ${DCMTK_DICTIONARY_DIR_AUTO}")
|
|
9 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR_AUTO}")
|
|
10 else()
|
|
11 add_definitions(-DDCMTK_DICTIONARY_DIR="${DCMTK_DICTIONARY_DIR}")
|
|
12 endif()
|
|
13
|
|
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)
|
|
19 DownloadPackage(
|
|
20 "219ad631b82031806147e4abbfba4fa4"
|
|
21 "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/dcmtk-3.6.0.zip"
|
|
22 "${DCMTK_SOURCES_DIR}")
|
|
23
|
|
24 IF(CMAKE_CROSSCOMPILING)
|
|
25 SET(C_CHAR_UNSIGNED 1 CACHE INTERNAL "Whether char is unsigned.")
|
|
26 ENDIF()
|
|
27 SET(DCMTK_SOURCE_DIR ${CMAKE_BINARY_DIR}/dcmtk-3.6.0)
|
|
28 include(${DCMTK_SOURCES_DIR}/CMake/CheckFunctionWithHeaderExists.cmake)
|
|
29 include(${DCMTK_SOURCES_DIR}/CMake/GenerateDCMTKConfigure.cmake)
|
|
30
|
|
31 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase")
|
|
32 set(HAVE_SSTREAM 1)
|
|
33 set(HAVE_PROTOTYPE_BZERO 1)
|
|
34 set(HAVE_PROTOTYPE_GETHOSTNAME 1)
|
|
35 set(HAVE_PROTOTYPE_GETSOCKOPT 1)
|
|
36 set(HAVE_PROTOTYPE_SETSOCKOPT 1)
|
|
37 set(HAVE_PROTOTYPE_CONNECT 1)
|
|
38 set(HAVE_PROTOTYPE_BIND 1)
|
|
39 set(HAVE_PROTOTYPE_ACCEPT 1)
|
|
40 set(HAVE_PROTOTYPE_SETSOCKNAME 1)
|
|
41 set(HAVE_PROTOTYPE_GETSOCKNAME 1)
|
|
42 endif()
|
|
43
|
|
44 CONFIGURE_FILE(
|
|
45 ${DCMTK_SOURCES_DIR}/CMake/osconfig.h.in
|
|
46 ${DCMTK_SOURCES_DIR}/config/include/dcmtk/config/osconfig.h)
|
|
47
|
|
48 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmnet/libsrc DCMTK_SOURCES)
|
|
49 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmdata/libsrc DCMTK_SOURCES)
|
|
50 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/ofstd/libsrc DCMTK_SOURCES)
|
|
51
|
|
52
|
|
53 if (ENABLE_JPEG_LOSSLESS)
|
|
54 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc DCMTK_SOURCES)
|
|
55 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8 DCMTK_SOURCES)
|
|
56 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12 DCMTK_SOURCES)
|
|
57 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16 DCMTK_SOURCES)
|
|
58 include_directories(
|
|
59 ${DCMTK_SOURCES_DIR}/dcmjpeg/include
|
|
60 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg8
|
|
61 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg12
|
|
62 ${DCMTK_SOURCES_DIR}/dcmjpeg/libijg16
|
|
63 ${DCMTK_SOURCES_DIR}/dcmimgle/include
|
|
64 )
|
|
65 endif()
|
|
66
|
|
67
|
|
68 if (ENABLE_JPEG_LOSSLESS)
|
|
69 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libsrc DCMTK_SOURCES)
|
|
70 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libcharls DCMTK_SOURCES)
|
|
71 include_directories(
|
|
72 ${DCMTK_SOURCES_DIR}/dcmjpeg/include
|
|
73 ${DCMTK_SOURCES_DIR}/dcmjpls/include
|
|
74 ${DCMTK_SOURCES_DIR}/dcmjpls/libcharls
|
|
75 )
|
|
76 list(REMOVE_ITEM DCMTK_SOURCES
|
|
77 ${DCMTK_SOURCES_DIR}/dcmjpls/libsrc/djcodece.cc)
|
|
78 list(APPEND DCMTK_SOURCES
|
|
79 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djrplol.cc)
|
|
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")
|
|
86 list(REMOVE_ITEM DCMTK_SOURCES
|
|
87 ${DCMTK_SOURCES_DIR}/oflog/libsrc/windebap.cc
|
|
88 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc
|
|
89 )
|
|
90 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|
91 list(REMOVE_ITEM DCMTK_SOURCES
|
|
92 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc
|
|
93 )
|
|
94
|
|
95 if (${CMAKE_COMPILER_IS_GNUCXX})
|
|
96 # This is a patch for MinGW64
|
|
97 execute_process(
|
|
98 COMMAND patch -p0 -i ${CMAKE_SOURCE_DIR}/Resources/Patches/dcmtk-mingw64.patch
|
|
99 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
100 )
|
|
101 endif()
|
|
102
|
|
103 endif()
|
|
104
|
|
105 list(REMOVE_ITEM DCMTK_SOURCES
|
|
106 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc
|
|
107 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc
|
|
108 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdictbi.cc
|
|
109 )
|
|
110
|
|
111 # This fixes crashes related to the destruction of the DCMTK OFLogger
|
|
112 # http://support.dcmtk.org/docs-snapshot/file_macros.html
|
|
113 add_definitions(
|
|
114 -DLOG4CPLUS_DISABLE_FATAL=1
|
|
115 -DDCMTK_VERSION_NUMBER=360
|
|
116 )
|
|
117
|
|
118 include_directories(
|
|
119 #${DCMTK_SOURCES_DIR}
|
|
120 ${DCMTK_SOURCES_DIR}/config/include
|
|
121 ${DCMTK_SOURCES_DIR}/dcmnet/include
|
|
122 ${DCMTK_SOURCES_DIR}/ofstd/include
|
|
123 ${DCMTK_SOURCES_DIR}/oflog/include
|
|
124 ${DCMTK_SOURCES_DIR}/dcmdata/include
|
|
125 )
|
|
126
|
|
127 source_group(ThirdParty\\Dcmtk REGULAR_EXPRESSION ${DCMTK_SOURCES_DIR}/.*)
|
|
128
|
|
129 set(DCMTK_BUNDLES_LOG4CPLUS 1)
|
|
130
|
|
131 if (STANDALONE_BUILD)
|
|
132 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=1)
|
|
133 else()
|
|
134 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0)
|
|
135 endif()
|
|
136
|
|
137 set(DCMTK_DICTIONARIES
|
|
138 DICTIONARY_DICOM ${DCMTK_SOURCES_DIR}/dcmdata/data/dicom.dic
|
|
139 DICTIONARY_PRIVATE ${DCMTK_SOURCES_DIR}/dcmdata/data/private.dic
|
|
140 DICTIONARY_DICONDE ${DCMTK_SOURCES_DIR}/dcmdata/data/diconde.dic
|
|
141 )
|
|
142
|
|
143 else()
|
|
144 # The following line allows to manually add libraries at the
|
|
145 # command-line, which is necessary for Ubuntu/Debian packages
|
|
146 set(tmp "${DCMTK_LIBRARIES}")
|
|
147 include(FindDCMTK)
|
|
148 list(APPEND DCMTK_LIBRARIES "${tmp}")
|
|
149
|
|
150 include_directories(${DCMTK_INCLUDE_DIR})
|
|
151 link_libraries(${DCMTK_LIBRARIES})
|
|
152
|
|
153 add_definitions(
|
|
154 -DHAVE_CONFIG_H=1
|
|
155 )
|
|
156
|
|
157 if (EXISTS "${DCMTK_DIR}/config/cfunix.h")
|
|
158 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/cfunix.h")
|
|
159 elseif (EXISTS "${DCMTK_DIR}/config/osconfig.h") # This is for Arch Linux
|
|
160 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/osconfig.h")
|
|
161 else()
|
|
162 message(FATAL_ERROR "Please install libdcmtk1-dev")
|
|
163 endif()
|
|
164
|
|
165 # Autodetection of the version of DCMTK
|
|
166 file(STRINGS
|
|
167 "${DCMTK_CONFIGURATION_FILE}"
|
|
168 DCMTK_VERSION_NUMBER1 REGEX
|
|
169 ".*PACKAGE_VERSION .*")
|
|
170
|
|
171 string(REGEX REPLACE
|
|
172 ".*PACKAGE_VERSION.*\"([0-9]*)\\.([0-9]*)\\.([0-9]*)\"$"
|
|
173 "\\1\\2\\3"
|
|
174 DCMTK_VERSION_NUMBER
|
|
175 ${DCMTK_VERSION_NUMBER1})
|
|
176
|
|
177 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0)
|
|
178
|
|
179 endif()
|
|
180
|
|
181 add_definitions(-DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER})
|
|
182 message("DCMTK version: ${DCMTK_VERSION_NUMBER}")
|