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
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.
30 # Get the system search path as a list.
32 STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
34 STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
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")
45 # Look for an installation or build tree.
47 FIND_PATH(ITK_DIR ITKConfig.cmake
48 # Look for an environment variable ITK_DIR.
51 # Look in places relative to the system executable search path.
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}"
76 # If ITK was found, load the configuration file to get the rest of the
80 INCLUDE(${ITK_DIR}/ITKConfig.cmake)
82 # Set USE_ITK_FILE for backward-compatability.
83 SET(USE_ITK_FILE ${ITK_USE_FILE})
87 MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
88 ENDIF(ITK_FIND_REQUIRED)