]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/include/Modules/FindGDCM.cmake
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / include / Modules / FindGDCM.cmake
1 # - Find a GDCM installation or build tree.
2 # The following variables are set if GDCM is found.  If GDCM is not
3 # found, GDCM_FOUND is set to false.
4 #  GDCM_FOUND         - Set to true when GDCM is found.
5 #  GDCM_USE_FILE      - CMake file to use GDCM.
6 #  GDCM_MAJOR_VERSION - The GDCM major version number.
7 #  GDCM_MINOR_VERSION - The GDCM minor version number 
8 #                       (odd non-release).
9 #  GDCM_BUILD_VERSION - The GDCM patch level 
10 #                       (meaningless for odd minor).
11 #  GDCM_INCLUDE_DIRS  - Include directories for GDCM
12 #  GDCM_LIBRARY_DIRS  - Link directories for GDCM libraries
13 #  GDCM_KITS          - List of GDCM kits, in CAPS 
14 #                      (COMMON,IO,) etc.
15 #  GDCM_LANGUAGES     - List of wrapped languages, in CAPS
16 #                      (TCL, PYHTON,) etc.
17 # The following cache entries must be set by the user to locate GDCM:
18 #  GDCM_DIR  - The directory containing GDCMConfig.cmake.  
19 #             This is either the root of the build tree,
20 #             or the lib/vtk directory.  This is the 
21 #             only cache entry.
22
23
24 # Construct consitent error messages for use below.
25 SET(GDCM_DIR_DESCRIPTION "directory containing GDCMConfig.cmake.  This is either the root of the build tree, or PREFIX/lib/GDCM for an installation.")
26 SET(GDCM_DIR_MESSAGE "GDCM not found.  Set the GDCM_DIR cmake cache entry to the ${GDCM_DIR_DESCRIPTION}")
27
28 # Search only if the location is not already known.
29 IF(NOT GDCM_DIR)
30   # Get the system search path as a list.
31   IF(UNIX)
32     STRING(REGEX MATCHALL "[^:]+" GDCM_DIR_SEARCH1 "$ENV{PATH}")
33   ELSE(UNIX)
34     STRING(REGEX REPLACE "\\\\" "/" GDCM_DIR_SEARCH1 "$ENV{PATH}")
35   ENDIF(UNIX)
36   STRING(REGEX REPLACE "/;" ";" GDCM_DIR_SEARCH2 "${GDCM_DIR_SEARCH1}")
37
38   # Construct a set of paths relative to the system search path.
39   SET(GDCM_DIR_SEARCH "")
40   FOREACH(dir ${GDCM_DIR_SEARCH2})
41     SET(GDCM_DIR_SEARCH ${GDCM_DIR_SEARCH}
42       ${dir}/../lib/GDCM
43       )
44   ENDFOREACH(dir)
45
46   #
47   # Look for an installation or build tree.
48   #
49   FIND_PATH(GDCM_DIR GDCMConfig.cmake
50     # Look for an environment variable GDCM_DIR.
51     $ENV{GDCM_DIR}
52
53     # Look in places relative to the system executable search path.
54     ${GDCM_DIR_SEARCH}
55
56     # Look in standard UNIX install locations.
57     /usr/local/lib/GDCM
58     /usr/lib/GDCM
59
60     # Read from the CMakeSetup registry entries.  It is likely that
61     # GDCM will have been recently built.
62     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
63     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
64     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
65     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
66     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
67     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
68     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
69     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
70     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
71     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
72
73     # Help the user find it if we cannot.
74     DOC "The ${GDCM_DIR_DESCRIPTION}"
75   )
76 ENDIF(NOT GDCM_DIR)
77
78 # If GDCM was found, load the configuration file to get the rest of the
79 # settings.
80 IF(GDCM_DIR)
81   # Make sure the GDCMConfig.cmake file exists in the directory provided.
82   IF(EXISTS ${GDCM_DIR}/GDCMConfig.cmake)
83
84     # We found GDCM.  Load the settings.
85     SET(GDCM_FOUND 1)
86     INCLUDE(${GDCM_DIR}/GDCMConfig.cmake)
87
88   ENDIF(EXISTS ${GDCM_DIR}/GDCMConfig.cmake)
89 ELSE(GDCM_DIR)
90   # We did not find GDCM.
91   SET(GDCM_FOUND 0)
92 ENDIF(GDCM_DIR)
93
94 #-----------------------------------------------------------------------------
95 IF(NOT GDCM_FOUND)
96   # GDCM not found, explain to the user how to specify its location.
97   IF(NOT GDCM_FIND_QUIETLY)
98     MESSAGE(FATAL_ERROR ${GDCM_DIR_MESSAGE})
99   ELSE(NOT GDCM_FIND_QUIETLY)
100     IF(GDCM_FIND_REQUIRED)
101       MESSAGE(FATAL_ERROR ${GDCM_DIR_MESSAGE})
102     ENDIF(GDCM_FIND_REQUIRED)
103   ENDIF(NOT GDCM_FIND_QUIETLY)
104 ENDIF(NOT GDCM_FOUND)