annotate Resources/CMake/DcmtkConfiguration.cmake @ 870:f4f5ab513157 jpeg

fix static builds
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 11 Jun 2014 09:13:22 +0200
parents f53358c70c05
children 816dccaeb7cf
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
857
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
53 if (ENABLE_JPEG)
856
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 )
857
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
65 list(REMOVE_ITEM DCMTK_SOURCES
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
66 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/ddpiimpl.cc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
67 )
856
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
68 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
69
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
70
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
71 if (ENABLE_JPEG_LOSSLESS)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
72 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libsrc DCMTK_SOURCES)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
73 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/dcmjpls/libcharls DCMTK_SOURCES)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
74 include_directories(
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
75 ${DCMTK_SOURCES_DIR}/dcmjpeg/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
76 ${DCMTK_SOURCES_DIR}/dcmjpls/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
77 ${DCMTK_SOURCES_DIR}/dcmjpls/libcharls
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
78 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
79 list(REMOVE_ITEM DCMTK_SOURCES
857
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
80 ${DCMTK_SOURCES_DIR}/dcmjpls/libsrc/djcodece.cc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
81 )
856
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
82 list(APPEND DCMTK_SOURCES
857
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
83 ${DCMTK_SOURCES_DIR}/dcmjpeg/libsrc/djrplol.cc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 856
diff changeset
84 )
856
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
85 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
86
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
87
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
88 # Source for the logging facility of DCMTK
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
89 AUX_SOURCE_DIRECTORY(${DCMTK_SOURCES_DIR}/oflog/libsrc DCMTK_SOURCES)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
90 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
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/windebap.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
93 ${DCMTK_SOURCES_DIR}/oflog/libsrc/winsock.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
94 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
95 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
96 list(REMOVE_ITEM DCMTK_SOURCES
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
97 ${DCMTK_SOURCES_DIR}/oflog/libsrc/unixsock.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
98 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
99
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
100 if (${CMAKE_COMPILER_IS_GNUCXX})
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
101 # This is a patch for MinGW64
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
102 execute_process(
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
103 COMMAND patch -p0 -i ${CMAKE_SOURCE_DIR}/Resources/Patches/dcmtk-mingw64.patch
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
104 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
105 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
106 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
107
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
108 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
109
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
110 list(REMOVE_ITEM DCMTK_SOURCES
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
111 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdictbi.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
112 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/mkdeftag.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
113 ${DCMTK_SOURCES_DIR}/dcmdata/libsrc/dcdictbi.cc
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
114 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
115
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
116 # This fixes crashes related to the destruction of the DCMTK OFLogger
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
117 # http://support.dcmtk.org/docs-snapshot/file_macros.html
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
118 add_definitions(
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
119 -DLOG4CPLUS_DISABLE_FATAL=1
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
120 -DDCMTK_VERSION_NUMBER=360
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
121 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
122
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
123 include_directories(
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
124 #${DCMTK_SOURCES_DIR}
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
125 ${DCMTK_SOURCES_DIR}/config/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
126 ${DCMTK_SOURCES_DIR}/dcmnet/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
127 ${DCMTK_SOURCES_DIR}/ofstd/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
128 ${DCMTK_SOURCES_DIR}/oflog/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
129 ${DCMTK_SOURCES_DIR}/dcmdata/include
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
130 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
131
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
132 source_group(ThirdParty\\Dcmtk REGULAR_EXPRESSION ${DCMTK_SOURCES_DIR}/.*)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
133
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
134 set(DCMTK_BUNDLES_LOG4CPLUS 1)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
135
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
136 if (STANDALONE_BUILD)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
137 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=1)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
138 else()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
139 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
140 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
141
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
142 set(DCMTK_DICTIONARIES
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
143 DICTIONARY_DICOM ${DCMTK_SOURCES_DIR}/dcmdata/data/dicom.dic
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
144 DICTIONARY_PRIVATE ${DCMTK_SOURCES_DIR}/dcmdata/data/private.dic
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
145 DICTIONARY_DICONDE ${DCMTK_SOURCES_DIR}/dcmdata/data/diconde.dic
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
146 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
147
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
148 else()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
149 # The following line allows to manually add libraries at the
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
150 # command-line, which is necessary for Ubuntu/Debian packages
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
151 set(tmp "${DCMTK_LIBRARIES}")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
152 include(FindDCMTK)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
153 list(APPEND DCMTK_LIBRARIES "${tmp}")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
154
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
155 include_directories(${DCMTK_INCLUDE_DIR})
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
156 link_libraries(${DCMTK_LIBRARIES})
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
157
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
158 add_definitions(
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
159 -DHAVE_CONFIG_H=1
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
160 )
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
161
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
162 if (EXISTS "${DCMTK_DIR}/config/cfunix.h")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
163 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/cfunix.h")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
164 elseif (EXISTS "${DCMTK_DIR}/config/osconfig.h") # This is for Arch Linux
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
165 set(DCMTK_CONFIGURATION_FILE "${DCMTK_DIR}/config/osconfig.h")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
166 else()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
167 message(FATAL_ERROR "Please install libdcmtk1-dev")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
168 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
169
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
170 # Autodetection of the version of DCMTK
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
171 file(STRINGS
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
172 "${DCMTK_CONFIGURATION_FILE}"
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
173 DCMTK_VERSION_NUMBER1 REGEX
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
174 ".*PACKAGE_VERSION .*")
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
175
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
176 string(REGEX REPLACE
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
177 ".*PACKAGE_VERSION.*\"([0-9]*)\\.([0-9]*)\\.([0-9]*)\"$"
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
178 "\\1\\2\\3"
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
179 DCMTK_VERSION_NUMBER
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
180 ${DCMTK_VERSION_NUMBER1})
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
181
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
182 add_definitions(-DDCMTK_USE_EMBEDDED_DICTIONARIES=0)
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
183
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
184 endif()
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
185
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
186 add_definitions(-DDCMTK_VERSION_NUMBER=${DCMTK_VERSION_NUMBER})
6944fc00962e fix windows build
jodogne
parents: 850
diff changeset
187 message("DCMTK version: ${DCMTK_VERSION_NUMBER}")