1 # - Find an ITK installation or build tree.
3 # When ITK is found, the ITKConfig.cmake file is sourced to setup the
4 # location and configuration of ITK. Please read this file, or
5 # ITKConfig.cmake.in from the ITK source tree for the full list of
6 # definitions. Of particular interest is ITK_USE_FILE, a CMake source file
7 # that can be included to set the include directories, library directories,
8 # and preprocessor macros. In addition to the variables read from
9 # ITKConfig.cmake, this find module also defines
10 # ITK_DIR - The directory containing ITKConfig.cmake.
11 # This is either the root of the build tree,
12 # or the lib/InsightToolkit directory.
13 # This is the only cache entry.
15 # ITK_FOUND - Whether ITK was found. If this is true,
18 # USE_ITK_FILE - The full path to the UseITK.cmake file.
19 # This is provided for backward
20 # compatability. Use ITK_USE_FILE
24 SET(ITK_DIR_STRING "directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.")
26 # Search only if the location is not already known.
28 # Get the system search path as a list.
30 STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
32 STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
34 STRING(REGEX REPLACE "/;" ";" ITK_DIR_SEARCH2 ${ITK_DIR_SEARCH1})
36 # Construct a set of paths relative to the system search path.
37 SET(ITK_DIR_SEARCH "")
38 FOREACH(dir ${ITK_DIR_SEARCH2})
39 SET(ITK_DIR_SEARCH ${ITK_DIR_SEARCH} "${dir}/../lib/InsightToolkit")
43 # Look for an installation or build tree.
45 FIND_PATH(ITK_DIR ITKConfig.cmake
46 # Look for an environment variable ITK_DIR.
49 # Look in places relative to the system executable search path.
52 # Look in standard UNIX install locations.
53 /usr/local/lib/InsightToolkit
54 /usr/lib/InsightToolkit
56 # Read from the CMakeSetup registry entries. It is likely that
57 # ITK will have been recently built.
58 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
59 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
60 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
61 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
62 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
63 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
64 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
65 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
66 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
67 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
69 # Help the user find it if we cannot.
70 DOC "The ${ITK_DIR_STRING}"
74 # If ITK was found, load the configuration file to get the rest of the
78 INCLUDE(${ITK_DIR}/ITKConfig.cmake)
80 # Set USE_ITK_FILE for backward-compatability.
81 SET(USE_ITK_FILE ${ITK_USE_FILE})
85 MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
86 ENDIF(ITK_FIND_REQUIRED)