Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
FindDCMTK.cmake
Go to the documentation of this file.
1 # adapted version of FindDCMTK, better suited for super-builds
2 
3 # - find DCMTK libraries and applications
4 #
5 
6 # DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK
7 # DCMTK_LIBRARIES - Files to link against to use DCMTK
8 # DCMTK_FOUND - If false, don't try to use DCMTK
9 # DCMTK_DIR - (optional) Source directory for DCMTK
10 #
11 # DCMTK_DIR can be used to make it simpler to find the various include
12 # directories and compiled libraries if you've just compiled it in the
13 # source tree. Just set it to the root of the tree where you extracted
14 # the source (default to /usr/include/dcmtk/)
15 
16 #=============================================================================
17 # Copyright 2004-2009 Kitware, Inc.
18 # Copyright 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
19 # Copyright 2010 Thomas Sondergaard <ts@medical-insight.com>
20 #
21 # Distributed under the OSI-approved BSD License (the "License");
22 # see accompanying file Copyright.txt for details.
23 #
24 # This software is distributed WITHOUT ANY WARRANTY; without even the
25 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 # See the License for more information.
27 #=============================================================================
28 # (To distributed this file outside of CMake, substitute the full
29 # License text for the above reference.)
30 
31 #
32 # Written for VXL by Amitha Perera.
33 # Upgraded for GDCM by Mathieu Malaterre.
34 # Modified for EasyViz by Thomas Sondergaard.
35 #
36 
37 # prefer DCMTK_DIR over default system paths like /usr/lib
38 set(CMAKE_PREFIX_PATH ${DCMTK_DIR}/lib ${CMAKE_PREFIX_PATH}) # this is given to FIND_LIBRARY or FIND_PATH
39 
40 if(NOT DCMTK_FOUND AND NOT DCMTK_DIR)
41  set(DCMTK_DIR
42  "/usr/include/dcmtk/"
43  CACHE
44  PATH
45  "Root of DCMTK source tree (optional).")
46  mark_as_advanced(DCMTK_DIR)
47 endif()
48 
49 # Find all libraries, store debug and release separately
50 foreach(lib
51  dcmpstat
52  dcmsr
53  dcmsign
54  dcmtls
55  dcmqrdb
56  dcmnet
57  dcmjpeg
58  dcmimage
59  dcmimgle
60  dcmdata
61  dcmrt
62  oflog
63  ofstd
64  ijg12
65  ijg16
66  ijg8
67  )
68 
69  # Find Release libraries
70  find_library(DCMTK_${lib}_LIBRARY_RELEASE
71  ${lib}
72  PATHS
73  ${DCMTK_DIR}/${lib}/libsrc
74  ${DCMTK_DIR}/${lib}/libsrc/Release
75  ${DCMTK_DIR}/${lib}/Release
76  ${DCMTK_DIR}/lib
77  ${DCMTK_DIR}/lib/Release
78  ${DCMTK_DIR}/dcmjpeg/lib${lib}/Release
79  NO_DEFAULT_PATH
80  )
81 
82  # Find Debug libraries
83  find_library(DCMTK_${lib}_LIBRARY_DEBUG
84  ${lib}${DCMTK_CMAKE_DEBUG_POSTFIX}
85  PATHS
86  ${DCMTK_DIR}/${lib}/libsrc
87  ${DCMTK_DIR}/${lib}/libsrc/Debug
88  ${DCMTK_DIR}/${lib}/Debug
89  ${DCMTK_DIR}/lib
90  ${DCMTK_DIR}/lib/Debug
91  ${DCMTK_DIR}/dcmjpeg/lib${lib}/Debug
92  NO_DEFAULT_PATH
93  )
94 
95  mark_as_advanced(DCMTK_${lib}_LIBRARY_RELEASE)
96  mark_as_advanced(DCMTK_${lib}_LIBRARY_DEBUG)
97 
98  # Add libraries to variable according to build type
99  set(DCMTK_${lib}_LIBRARY)
100  if(DCMTK_${lib}_LIBRARY_RELEASE)
101  list(APPEND DCMTK_LIBRARIES optimized ${DCMTK_${lib}_LIBRARY_RELEASE})
102  list(APPEND DCMTK_${lib}_LIBRARY optimized ${DCMTK_${lib}_LIBRARY_RELEASE})
103  endif()
104 
105  if(DCMTK_${lib}_LIBRARY_DEBUG)
106  list(APPEND DCMTK_LIBRARIES debug ${DCMTK_${lib}_LIBRARY_DEBUG})
107  list(APPEND DCMTK_${lib}_LIBRARY debug ${DCMTK_${lib}_LIBRARY_DEBUG})
108  endif()
109 
110 endforeach()
111 
112 set(DCMTK_config_TEST_HEADER osconfig.h)
113 set(DCMTK_dcmdata_TEST_HEADER dctypes.h)
114 set(DCMTK_dcmimage_TEST_HEADER dicoimg.h)
115 set(DCMTK_dcmimgle_TEST_HEADER dcmimage.h)
116 set(DCMTK_dcmjpeg_TEST_HEADER djdecode.h)
117 set(DCMTK_dcmnet_TEST_HEADER assoc.h)
118 set(DCMTK_dcmpstat_TEST_HEADER dcmpstat.h)
119 set(DCMTK_dcmqrdb_TEST_HEADER dcmqrdba.h)
120 set(DCMTK_dcmsign_TEST_HEADER sicert.h)
121 set(DCMTK_dcmsr_TEST_HEADER dsrtree.h)
122 set(DCMTK_dcmtls_TEST_HEADER tlslayer.h)
123 set(DCMTK_ofstd_TEST_HEADER ofstdinc.h)
124 set(DCMTK_dcmrt_TEST_HEADER drtstrct.h)
125 
126 foreach(dir
127  config
128  dcmdata
129  dcmimage
130  dcmimgle
131  dcmjpeg
132  dcmnet
133  dcmpstat
134  dcmqrdb
135  dcmsign
136  dcmsr
137  dcmtls
138  dcmrt
139  ofstd)
140  find_path(DCMTK_${dir}_INCLUDE_DIR
141  ${DCMTK_${dir}_TEST_HEADER}
142  PATHS
143  ${DCMTK_DIR}/${dir}/include
144  ${DCMTK_DIR}/${dir}
145  ${DCMTK_DIR}/include/dcmtk/${dir}
146  ${DCMTK_DIR}/include/${dir})
147 
148  mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR)
149  #message("** DCMTKs ${dir} found at ${DCMTK_${dir}_INCLUDE_DIR}")
150 
151  if(DCMTK_${dir}_INCLUDE_DIR)
152  # add the 'include' path so eg
153  #include "dcmtk/dcmimgle/dcmimage.h"
154  # works
155  get_filename_component(_include ${DCMTK_${dir}_INCLUDE_DIR} PATH)
156  get_filename_component(_include ${_include} PATH)
157  list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_${dir}_INCLUDE_DIR} ${_include})
158  endif()
159 endforeach()
160 
161 if(WIN32)
162  list(APPEND DCMTK_LIBRARIES netapi32 wsock32)
163 endif()
164 
165 if(DCMTK_ofstd_INCLUDE_DIR)
166  get_filename_component(DCMTK_dcmtk_INCLUDE_DIR
167  ${DCMTK_ofstd_INCLUDE_DIR}
168  PATH
169  CACHE)
170  list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR})
171  mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR)
172 endif()
173 
174 include(FindPackageHandleStandardArgs)
175 find_package_handle_standard_args(DCMTK DEFAULT_MSG
176  DCMTK_config_INCLUDE_DIR
177  DCMTK_ofstd_INCLUDE_DIR
178  DCMTK_ofstd_LIBRARY
179  DCMTK_dcmdata_INCLUDE_DIR
180  DCMTK_dcmdata_LIBRARY
181  DCMTK_dcmimgle_INCLUDE_DIR
182  DCMTK_dcmimgle_LIBRARY
183  )
184 
185 # Compatibility: This variable is deprecated
186 set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS})