2 # Find a VTK installation or build tree.
4 # The following variables are set if VTK is found. If VTK is not
5 # found, VTK_FOUND is set to false.
7 # VTK_FOUND - Set to true when VTK is found.
8 # VTK_USE_FILE - CMake source file to setup a project to use VTK.
9 # VTK_MAJOR_VERSION - The VTK major version number.
10 # VTK_MINOR_VERSION - The VTK minor version number (odd for non-release).
11 # VTK_BUILD_VERSION - The VTK patch level (meaningless for odd minor).
12 # VTK_INCLUDE_DIRS - Include directories for VTK headers.
13 # VTK_LIBRARY_DIRS - Link directories for VTK libraries.
14 # VTK_KITS - List of VTK kits, in all CAPS (COMMON, IO, ...).
15 # VTK_LANGUAGES - List of wrapped languages, in all CAPS (TCL, ...).
17 # The following cache entries must be set by the user to locate VTK:
19 # VTK_DIR - The directory containing VTKConfig.cmake. This is either
20 # the root of the build tree, or the lib/vtk
21 # directory. This is the only cache entry.
23 # The following variables are set for backward compatability and
24 # should not be used in new code:
26 # USE_VTK_FILE - The full path to the UseVTK.cmake file. This is provided
27 # for backward compatability. Use VTK_USE_FILE instead.
30 # Construct consitent error messages for use below.
31 SET(VTK_DIR_DESCRIPTION "directory containing VTKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/vtk for an installation. For VTK 4.0, this is the location of UseVTK.cmake. This is either the root of the build tree or PREFIX/include/vtk for an installation.")
32 SET(VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}")
34 # Search only if the location is not already known.
36 # Get the system search path as a list.
38 STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 "$ENV{PATH}")
40 STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 "$ENV{PATH}")
42 STRING(REGEX REPLACE "/;" ";" VTK_DIR_SEARCH2 "${VTK_DIR_SEARCH1}")
44 # Construct a set of paths relative to the system search path.
45 SET(VTK_DIR_SEARCH "")
46 FOREACH(dir ${VTK_DIR_SEARCH2})
47 SET(VTK_DIR_SEARCH ${VTK_DIR_SEARCH} "${dir}/../lib/vtk")
50 # Old scripts may set these directories in the CMakeCache.txt file.
51 # They can tell us where to find VTKConfig.cmake.
52 SET(VTK_DIR_SEARCH_LEGACY "")
53 IF(VTK_BINARY_PATH AND USE_BUILT_VTK)
54 SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
55 ENDIF(VTK_BINARY_PATH AND USE_BUILT_VTK)
56 IF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
57 SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
58 ${VTK_INSTALL_PATH}/lib/vtk)
59 ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
62 # Look for an installation or build tree.
64 FIND_PATH(VTK_DIR UseVTK.cmake
65 # Support legacy cache files.
66 ${VTK_DIR_SEARCH_LEGACY}
68 # Look for an environment variable VTK_DIR.
71 # Look in places relative to the system executable search path.
74 # Look in standard UNIX install locations.
78 # Read from the CMakeSetup registry entries. It is likely that
79 # VTK will have been recently built.
80 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
81 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
82 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
83 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
84 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
85 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
86 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
87 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
88 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
89 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
91 # Help the user find it if we cannot.
92 DOC "The ${VTK_DIR_DESCRIPTION}"
96 # If VTK was found, load the configuration file to get the rest of the
99 # Make sure the VTKConfig.cmake file exists in the directory provided.
100 IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
102 # We found VTK. Load the settings.
104 INCLUDE(${VTK_DIR}/VTKConfig.cmake)
106 ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
107 IF(EXISTS ${VTK_DIR}/UseVTK.cmake)
108 # We found VTK 4.0 (UseVTK.cmake exists, but not VTKConfig.cmake).
110 # Load settings for VTK 4.0.
111 INCLUDE(UseVTKConfig40)
112 ELSE(EXISTS ${VTK_DIR}/UseVTK.cmake)
113 # We did not find VTK.
115 ENDIF(EXISTS ${VTK_DIR}/UseVTK.cmake)
116 ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
118 # We did not find VTK.
122 #-----------------------------------------------------------------------------
124 # Set USE_VTK_FILE for backward-compatability.
125 SET(USE_VTK_FILE ${VTK_USE_FILE})
127 # VTK not found, explain to the user how to specify its location.
128 IF(NOT VTK_FIND_QUIETLY)
129 MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
130 ELSE(NOT VTK_FIND_QUIETLY)
131 IF(VTK_FIND_REQUIRED)
132 MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
133 ENDIF(VTK_FIND_REQUIRED)
134 ENDIF(NOT VTK_FIND_QUIETLY)