STYLE: Nightly Version update
[cmake.git] / Modules / FindITK.cmake
blob40c321b5f5c81c87e7067a8ebf76d51b202dc54d
2 # Find an ITK installation or build tree.
4 # When ITK is found, the ITKConfig.cmake file is sourced to setup the
5 # location and configuration of ITK.  Please read this file, or
6 # ITKConfig.cmake.in from the ITK source tree for the full list of
7 # definitions.  Of particular interest is
9 # ITK_USE_FILE          - A CMake source file that can be included
10 #                         to set the include directories, library
11 #                         directories, and preprocessor macros.
13 # In addition to the variables read from ITKConfig.cmake, this find
14 # module also defines
16 # ITK_DIR      - The directory containing ITKConfig.cmake.  This is either
17 #                the root of the build tree, or the lib/InsightToolkit
18 #                directory.  This is the only cache entry.
20 # ITK_FOUND    - Whether ITK was found.  If this is true, ITK_DIR is okay.
22 # USE_ITK_FILE - The full path to the UseITK.cmake file.  This is provided
23 #                for backward compatability.  Use ITK_USE_FILE instead.
26 SET(ITK_DIR_STRING "directory containing ITKConfig.cmake.  This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.")
28 # Search only if the location is not already known.
29 IF(NOT ITK_DIR)
30   # Get the system search path as a list.
31   IF(UNIX)
32     STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
33   ELSE(UNIX)
34     STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
35   ENDIF(UNIX)
36   STRING(REGEX REPLACE "/;" ";" ITK_DIR_SEARCH2 ${ITK_DIR_SEARCH1})
38   # Construct a set of paths relative to the system search path.
39   SET(ITK_DIR_SEARCH "")
40   FOREACH(dir ${ITK_DIR_SEARCH2})
41     SET(ITK_DIR_SEARCH ${ITK_DIR_SEARCH} "${dir}/../lib/InsightToolkit")
42   ENDFOREACH(dir)
44   #
45   # Look for an installation or build tree.
46   #
47   FIND_PATH(ITK_DIR ITKConfig.cmake
48     # Look for an environment variable ITK_DIR.
49     $ENV{ITK_DIR}
51     # Look in places relative to the system executable search path.
52     ${ITK_DIR_SEARCH}
54     # Look in standard UNIX install locations.
55     /usr/local/lib/InsightToolkit
56     /usr/lib/InsightToolkit
58     # Read from the CMakeSetup registry entries.  It is likely that
59     # ITK will have been recently built.
60     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
61     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
62     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
63     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
64     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
65     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
66     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
67     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
68     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
69     [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
71     # Help the user find it if we cannot.
72     DOC "The ${ITK_DIR_STRING}"
73   )
74 ENDIF(NOT ITK_DIR)
76 # If ITK was found, load the configuration file to get the rest of the
77 # settings.
78 IF(ITK_DIR)
79   SET(ITK_FOUND 1)
80   INCLUDE(${ITK_DIR}/ITKConfig.cmake)
82   # Set USE_ITK_FILE for backward-compatability.
83   SET(USE_ITK_FILE ${ITK_USE_FILE})
84 ELSE(ITK_DIR)
85   SET(ITK_FOUND 0)
86   IF(ITK_FIND_REQUIRED)
87     MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
88   ENDIF(ITK_FIND_REQUIRED)
89 ENDIF(ITK_DIR)