annotate Resources/CMake/DcmtkConfiguration.cmake @ 856:6944fc00962e jpeg

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