1 # - Find a VTK installation or build tree.
2 # The following variables are set if VTK is found. If VTK is not
3 # found, VTK_FOUND is set to false.
4 # VTK_FOUND - Set to true when VTK is found.
5 # VTK_USE_FILE - CMake file to use VTK.
6 # VTK_MAJOR_VERSION - The VTK major version number.
7 # VTK_MINOR_VERSION - The VTK minor version number
9 # VTK_BUILD_VERSION - The VTK patch level
10 # (meaningless for odd minor).
11 # VTK_INCLUDE_DIRS - Include directories for VTK
12 # VTK_LIBRARY_DIRS - Link directories for VTK libraries
13 # VTK_KITS - List of VTK kits, in CAPS
15 # VTK_LANGUAGES - List of wrapped languages, in CAPS
17 # The following cache entries must be set by the user to locate VTK:
18 # VTK_DIR - The directory containing VTKConfig.cmake.
19 # This is either the root of the build tree,
20 # or the lib/vtk directory. This is the
22 # The following variables are set for backward compatibility and
23 # should not be used in new code:
24 # USE_VTK_FILE - The full path to the UseVTK.cmake file.
25 # This is provided for backward
26 # compatibility. Use VTK_USE_FILE
30 #=============================================================================
31 # Copyright 2001-2009 Kitware, Inc.
33 # Distributed under the OSI-approved BSD License (the "License");
34 # see accompanying file Copyright.txt for details.
36 # This software is distributed WITHOUT ANY WARRANTY; without even the
37 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
38 # See the License for more information.
39 #=============================================================================
40 # (To distributed this file outside of CMake, substitute the full
41 # License text for the above reference.)
46 # VTK 4.0 did not provide VTKConfig.cmake.
47 IF("${VTK_FIND_VERSION}" VERSION_LESS 4.1)
54 # Construct consitent error messages for use below.
55 SET(VTK_DIR_DESCRIPTION "directory containing VTKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/vtk for an installation.")
57 SET(VTK_DIR_DESCRIPTION "${VTK_DIR_DESCRIPTION} 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.")
59 SET(VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}")
61 # Check whether VTK 4.0 has already been found.
62 IF(_VTK_40_ALLOW AND VTK_DIR)
63 IF(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake)
65 INCLUDE(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings.
69 # Use the Config mode of the find_package() command to find VTKConfig.
70 # If this succeeds (possibly because VTK_DIR is already set), the
71 # command will have already loaded VTKConfig.cmake and set VTK_FOUND.
72 IF(NOT _VTK_40_ONLY AND NOT VTK_FOUND)
73 FIND_PACKAGE(VTK QUIET NO_MODULE)
76 # Special search for VTK 4.0.
77 IF(_VTK_40_ALLOW AND NOT VTK_DIR)
78 # Old scripts may set these directories in the CMakeCache.txt file.
79 # They can tell us where to find VTKConfig.cmake.
80 SET(VTK_DIR_SEARCH_LEGACY "")
81 IF(VTK_BINARY_PATH AND USE_BUILT_VTK)
82 SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
83 ENDIF(VTK_BINARY_PATH AND USE_BUILT_VTK)
84 IF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
85 SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
86 ${VTK_INSTALL_PATH}/lib/vtk)
87 ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
89 # Look for UseVTK.cmake in build trees or under <prefix>/include/vtk.
92 PATH_SUFFIXES vtk-4.0 vtk
97 # Support legacy cache files.
98 ${VTK_DIR_SEARCH_LEGACY}
100 # Read from the CMakeSetup registry entries. It is likely that
101 # VTK will have been recently built.
102 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
103 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
104 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
105 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
106 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
107 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
108 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
109 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
110 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
111 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
113 # Help the user find it if we cannot.
114 DOC "The ${VTK_DIR_DESCRIPTION}"
118 IF(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake)
120 INCLUDE(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings.
122 # We found the wrong version. Pretend we did not find it.
123 SET(VTK_DIR "VTK_DIR-NOTFOUND" CACHE PATH "The ${VTK_DIR_DESCRIPTION}" FORCE)
128 #-----------------------------------------------------------------------------
130 # Set USE_VTK_FILE for backward-compatability.
131 SET(USE_VTK_FILE ${VTK_USE_FILE})
133 # VTK not found, explain to the user how to specify its location.
134 IF(VTK_FIND_REQUIRED)
135 MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
136 ELSE(VTK_FIND_REQUIRED)
137 IF(NOT VTK_FIND_QUIETLY)
138 MESSAGE(STATUS ${VTK_DIR_MESSAGE})
139 ENDIF(NOT VTK_FIND_QUIETLY)
140 ENDIF(VTK_FIND_REQUIRED)