annotate Resources/CMake/DcmtkConfiguration.cmake @ 849:dcd8a3e4d298 jpeg

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