[Cmake-commits] [cmake-commits] king committed FindVTK.cmake 1.31 1.32
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 7 14:48:24 EDT 2009
Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv2035/Modules
Modified Files:
FindVTK.cmake
Log Message:
Modernize FindVTK module
This teaches the FindVTK module to use the Config mode of find_package()
to search for VTKConfig in the common case. The old search method based
on find_path() and UseVTK is now used only to search for VTK 4.0.
This approach avoids the need to update the module for each new VTK
version because find_package(VTK) automatically searches "lib/vtk*". It
also addresses issue #9105 since find_package searches lib64 paths too.
Index: FindVTK.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/FindVTK.cmake,v
retrieving revision 1.31
retrieving revision 1.32
diff -C 2 -d -r1.31 -r1.32
*** FindVTK.cmake 28 Sep 2009 15:45:50 -0000 1.31
--- FindVTK.cmake 7 Oct 2009 18:48:22 -0000 1.32
***************
*** 41,70 ****
# License text for the above reference.)
# Construct consitent error messages for use below.
! 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.")
SET(VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}")
! # Search only if the location is not already known.
! IF(NOT VTK_DIR)
! # Get the system search path as a list.
! IF(UNIX)
! STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 "$ENV{PATH}")
! ELSE(UNIX)
! STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 "$ENV{PATH}")
! ENDIF(UNIX)
! STRING(REGEX REPLACE "/;" ";" VTK_DIR_SEARCH2 "${VTK_DIR_SEARCH1}")
! # Construct a set of paths relative to the system search path.
! SET(VTK_DIR_SEARCH "")
! FOREACH(dir ${VTK_DIR_SEARCH2})
! SET(VTK_DIR_SEARCH ${VTK_DIR_SEARCH}
! ${dir}/../lib/vtk-5.4
! ${dir}/../lib/vtk-5.2
! ${dir}/../lib/vtk-5.1
! ${dir}/../lib/vtk-5.0
! ${dir}/../lib/vtk
! )
! ENDFOREACH(dir)
# Old scripts may set these directories in the CMakeCache.txt file.
# They can tell us where to find VTKConfig.cmake.
--- 41,79 ----
# License text for the above reference.)
+ # Assume not found.
+ SET(VTK_FOUND 0)
+
+ # VTK 4.0 did not provide VTKConfig.cmake.
+ IF("${VTK_FIND_VERSION}" VERSION_LESS 4.1)
+ SET(_VTK_40_ALLOW 1)
+ IF(VTK_FIND_VERSION)
+ SET(_VTK_40_ONLY 1)
+ ENDIF()
+ ENDIF()
+
# Construct consitent error messages for use below.
! 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}")
! # Check whether VTK 4.0 has already been found.
! IF(_VTK_40_ALLOW AND VTK_DIR)
! IF(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake)
! SET(VTK_FOUND 1)
! INCLUDE(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings.
! ENDIF()
! ENDIF()
! # 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.
! IF(NOT _VTK_40_ONLY AND NOT VTK_FOUND)
! FIND_PACKAGE(VTK QUIET NO_MODULE)
! ENDIF()
+ # Special search for VTK 4.0.
+ IF(_VTK_40_ALLOW AND NOT VTK_DIR)
# Old scripts may set these directories in the CMakeCache.txt file.
# They can tell us where to find VTKConfig.cmake.
***************
*** 78,97 ****
ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
! #
! # Look for an installation or build tree.
! #
! FIND_PATH(VTK_DIR UseVTK.cmake
! # Support legacy cache files.
! ${VTK_DIR_SEARCH_LEGACY}
!
! # Look for an environment variable VTK_DIR.
! $ENV{VTK_DIR}
! # Look in places relative to the system executable search path.
! ${VTK_DIR_SEARCH}
! # Look in standard UNIX install locations.
! /usr/local/lib/vtk
! /usr/lib/vtk
# Read from the CMakeSetup registry entries. It is likely that
--- 87,100 ----
ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
! # Look for UseVTK.cmake in build trees or under <prefix>/include/vtk.
! FIND_PATH(VTK_DIR
! NAMES UseVTK.cmake
! PATH_SUFFIXES vtk-4.0 vtk
! HINTS $ENV{VTK_DIR}
! PATHS
! # Support legacy cache files.
! ${VTK_DIR_SEARCH_LEGACY}
# Read from the CMakeSetup registry entries. It is likely that
***************
*** 110,141 ****
# Help the user find it if we cannot.
DOC "The ${VTK_DIR_DESCRIPTION}"
! )
! ENDIF(NOT VTK_DIR)
!
! # If VTK was found, load the configuration file to get the rest of the
! # settings.
! IF(VTK_DIR)
! # Make sure the VTKConfig.cmake file exists in the directory provided.
! IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
!
! # We found VTK. Load the settings.
! SET(VTK_FOUND 1)
! INCLUDE(${VTK_DIR}/VTKConfig.cmake)
! ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
! IF(EXISTS ${VTK_DIR}/UseVTK.cmake)
! # We found VTK 4.0 (UseVTK.cmake exists, but not VTKConfig.cmake).
SET(VTK_FOUND 1)
! # Load settings for VTK 4.0.
! INCLUDE(UseVTKConfig40)
! ELSE(EXISTS ${VTK_DIR}/UseVTK.cmake)
! # We did not find VTK.
! SET(VTK_FOUND 0)
! ENDIF(EXISTS ${VTK_DIR}/UseVTK.cmake)
! ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
! ELSE(VTK_DIR)
! # We did not find VTK.
! SET(VTK_FOUND 0)
! ENDIF(VTK_DIR)
#-----------------------------------------------------------------------------
--- 113,128 ----
# Help the user find it if we cannot.
DOC "The ${VTK_DIR_DESCRIPTION}"
! )
! IF(VTK_DIR)
! IF(EXISTS ${VTK_DIR}/UseVTK.cmake AND NOT EXISTS ${VTK_DIR}/VTKConfig.cmake)
SET(VTK_FOUND 1)
! INCLUDE(UseVTKConfig40) # No VTKConfig; load VTK 4.0 settings.
! ELSE()
! # We found the wrong version. Pretend we did not find it.
! SET(VTK_DIR "VTK_DIR-NOTFOUND" CACHE PATH "The ${VTK_DIR_DESCRIPTION}" FORCE)
! ENDIF()
! ENDIF()
! ENDIF()
#-----------------------------------------------------------------------------
More information about the Cmake-commits
mailing list