2013-10-15 19:17:36 +04:00
#.rst:
# FindVTK
# -------
#
# Find a VTK installation or build tree.
#
# The following variables are set if VTK is found. If VTK is not found,
# VTK_FOUND is set to false.
#
# ::
#
# VTK_FOUND - Set to true when VTK is found.
# VTK_USE_FILE - CMake file to use VTK.
# VTK_MAJOR_VERSION - The VTK major version number.
# VTK_MINOR_VERSION - The VTK minor version number
# (odd non-release).
# VTK_BUILD_VERSION - The VTK patch level
# (meaningless for odd minor).
# VTK_INCLUDE_DIRS - Include directories for VTK
# VTK_LIBRARY_DIRS - Link directories for VTK libraries
# VTK_KITS - List of VTK kits, in CAPS
# (COMMON,IO,) etc.
# VTK_LANGUAGES - List of wrapped languages, in CAPS
# (TCL, PYHTON,) etc.
#
2002-12-05 18:47:18 +03:00
# The following cache entries must be set by the user to locate VTK:
2001-09-19 22:52:59 +04:00
#
2013-10-15 19:17:36 +04:00
# ::
#
# VTK_DIR - The directory containing VTKConfig.cmake.
# This is either the root of the build tree,
# or the lib/vtk directory. This is the
# only cache entry.
#
# The following variables are set for backward compatibility and should
# not be used in new code:
#
# ::
#
# USE_VTK_FILE - The full path to the UseVTK.cmake file.
# This is provided for backward
# compatibility. Use VTK_USE_FILE
# instead.
2001-12-21 22:40:33 +03:00
2009-09-28 19:45:50 +04:00
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
2010-08-07 04:48:47 +04:00
# (To distribute this file outside of CMake, substitute the full
2009-09-28 19:45:50 +04:00
# License text for the above reference.)
2009-10-07 22:48:22 +04:00
# Assume not found.
2012-08-13 21:47:32 +04:00
set ( VTK_FOUND 0 )
2009-10-07 22:48:22 +04:00
# VTK 4.0 did not provide VTKConfig.cmake.
2012-08-13 21:47:32 +04:00
if ( "${VTK_FIND_VERSION}" VERSION_LESS 4.1 )
set ( _VTK_40_ALLOW 1 )
if ( VTK_FIND_VERSION )
set ( _VTK_40_ONLY 1 )
endif ( )
endif ( )
2009-10-07 22:48:22 +04:00
2012-11-07 20:13:09 +04:00
# Construct consistent error messages for use below.
2012-08-13 21:47:32 +04:00
set ( VTK_DIR_DESCRIPTION "directory containing VTKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/vtk for an installation." )
if ( _VTK_40_ALLOW )
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." )
endif ( )
set ( VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}" )
2002-01-08 01:29:06 +03:00
2009-10-07 22:48:22 +04:00
# Check whether VTK 4.0 has already been found.
2012-08-13 21:47:32 +04:00
if ( _VTK_40_ALLOW AND VTK_DIR )
if ( EXISTS ${ VTK_DIR } /UseVTK.cmake AND NOT EXISTS ${ VTK_DIR } /VTKConfig.cmake )
set ( VTK_FOUND 1 )
2012-11-04 00:35:44 +04:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /UseVTKConfig40.cmake ) # No VTKConfig; load VTK 4.0 settings.
2012-08-13 21:47:32 +04:00
endif ( )
endif ( )
2001-09-21 01:31:38 +04:00
2009-10-07 22:48:22 +04:00
# Use the Config mode of the find_package() command to find VTKConfig.
# If this succeeds (possibly because VTK_DIR is already set), the
# command will have already loaded VTKConfig.cmake and set VTK_FOUND.
2012-08-13 21:47:32 +04:00
if ( NOT _VTK_40_ONLY AND NOT VTK_FOUND )
find_package ( VTK QUIET NO_MODULE )
endif ( )
2001-05-23 19:34:19 +04:00
2009-10-07 22:48:22 +04:00
# Special search for VTK 4.0.
2012-08-13 21:47:32 +04:00
if ( _VTK_40_ALLOW AND NOT VTK_DIR )
2002-11-20 21:37:52 +03:00
# Old scripts may set these directories in the CMakeCache.txt file.
# They can tell us where to find VTKConfig.cmake.
2012-08-13 21:47:32 +04:00
set ( VTK_DIR_SEARCH_LEGACY "" )
if ( VTK_BINARY_PATH AND USE_BUILT_VTK )
set ( VTK_DIR_SEARCH_LEGACY ${ VTK_DIR_SEARCH_LEGACY } ${ VTK_BINARY_PATH } )
2012-08-13 21:50:14 +04:00
endif ( )
2012-08-13 21:47:32 +04:00
if ( VTK_INSTALL_PATH AND USE_INSTALLED_VTK )
set ( VTK_DIR_SEARCH_LEGACY ${ VTK_DIR_SEARCH_LEGACY }
2002-11-20 21:37:52 +03:00
$ { V T K _ I N S T A L L _ P A T H } / l i b / v t k )
2012-08-13 21:50:14 +04:00
endif ( )
2001-05-23 19:34:19 +04:00
2009-10-07 22:48:22 +04:00
# Look for UseVTK.cmake in build trees or under <prefix>/include/vtk.
2012-08-13 21:47:32 +04:00
find_path ( VTK_DIR
2009-10-07 22:48:22 +04:00
N A M E S U s e V T K . c m a k e
P A T H _ S U F F I X E S v t k - 4 . 0 v t k
2012-03-29 02:00:54 +04:00
H I N T S E N V V T K _ D I R
2004-04-26 19:00:41 +04:00
2009-10-07 22:48:22 +04:00
P A T H S
2002-11-20 21:37:52 +03:00
2009-10-07 22:48:22 +04:00
# Support legacy cache files.
$ { V T K _ D I R _ S E A R C H _ L E G A C Y }
2002-11-20 21:37:52 +03:00
# Read from the CMakeSetup registry entries. It is likely that
# VTK will have been recently built.
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 1 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 2 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 3 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 4 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 5 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 6 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 7 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 8 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 9 ]
[ H K E Y _ C U R R E N T _ U S E R \ \ S o f t w a r e \ \ K i t w a r e \ \ C M a k e S e t u p \ \ S e t t i n g s \ \ S t a r t P a t h ; W h e r e B u i l d 1 0 ]
# Help the user find it if we cannot.
D O C " T h e $ { V T K _ D I R _ D E S C R I P T I O N } "
2009-10-07 22:48:22 +04:00
)
2002-11-20 21:37:52 +03:00
2012-08-13 21:47:32 +04:00
if ( VTK_DIR )
if ( EXISTS ${ VTK_DIR } /UseVTK.cmake AND NOT EXISTS ${ VTK_DIR } /VTKConfig.cmake )
set ( VTK_FOUND 1 )
2012-11-04 00:35:44 +04:00
include ( ${ CMAKE_CURRENT_LIST_DIR } /UseVTKConfig40.cmake ) # No VTKConfig; load VTK 4.0 settings.
2012-08-13 21:47:32 +04:00
else ( )
2009-10-07 22:48:22 +04:00
# We found the wrong version. Pretend we did not find it.
2012-08-13 21:47:32 +04:00
set ( VTK_DIR "VTK_DIR-NOTFOUND" CACHE PATH "The ${VTK_DIR_DESCRIPTION}" FORCE )
endif ( )
endif ( )
endif ( )
2002-11-20 21:37:52 +03:00
2002-12-05 18:47:18 +03:00
#-----------------------------------------------------------------------------
2012-08-13 21:47:32 +04:00
if ( VTK_FOUND )
2012-11-07 20:13:09 +04:00
# Set USE_VTK_FILE for backward-compatibility.
2012-08-13 21:47:32 +04:00
set ( USE_VTK_FILE ${ VTK_USE_FILE } )
2012-08-13 21:50:14 +04:00
else ( )
2002-11-21 00:23:20 +03:00
# VTK not found, explain to the user how to specify its location.
2012-08-13 21:47:32 +04:00
if ( VTK_FIND_REQUIRED )
message ( FATAL_ERROR ${ VTK_DIR_MESSAGE } )
2012-08-13 21:50:14 +04:00
else ( )
2012-08-13 21:47:32 +04:00
if ( NOT VTK_FIND_QUIETLY )
message ( STATUS ${ VTK_DIR_MESSAGE } )
2012-08-13 21:50:14 +04:00
endif ( )
endif ( )
endif ( )