ENH: Support object lists longer than 128K on MSVC
[cmake.git] / Modules / FindITK.cmake
blob2e2b0341b4eeb5772902401e906f04839cba13d2
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.
14 #   
15 #  ITK_FOUND - Whether ITK was found.  If this is true, 
16 #              ITK_DIR is okay.
18 #  USE_ITK_FILE - The full path to the UseITK.cmake file.  
19 #                 This is provided for backward 
20 #                 compatability.  Use ITK_USE_FILE
21 #                 instead.
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.
27 IF(NOT ITK_DIR)
28   # Get the system search path as a list.
29   IF(UNIX)
30     STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
31   ELSE(UNIX)
32     STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
33   ENDIF(UNIX)
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")
40   ENDFOREACH(dir)
42   #
43   # Look for an installation or build tree.
44   #
45   FIND_PATH(ITK_DIR ITKConfig.cmake
46     # Look for an environment variable ITK_DIR.
47     $ENV{ITK_DIR}
49     # Look in places relative to the system executable search path.
50     ${ITK_DIR_SEARCH}
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}"
71   )
72 ENDIF(NOT ITK_DIR)
74 # If ITK was found, load the configuration file to get the rest of the
75 # settings.
76 IF(ITK_DIR)
77   SET(ITK_FOUND 1)
78   INCLUDE(${ITK_DIR}/ITKConfig.cmake)
80   # Set USE_ITK_FILE for backward-compatability.
81   SET(USE_ITK_FILE ${ITK_USE_FILE})
82 ELSE(ITK_DIR)
83   SET(ITK_FOUND 0)
84   IF(ITK_FIND_REQUIRED)
85     MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
86   ENDIF(ITK_FIND_REQUIRED)
87 ENDIF(ITK_DIR)