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