FindVTK.cmake 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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
  8. # (odd non-release).
  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
  14. # (COMMON,IO,) etc.
  15. # VTK_LANGUAGES - List of wrapped languages, in CAPS
  16. # (TCL, PYHTON,) etc.
  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
  21. # only cache entry.
  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
  27. # instead.
  28. #
  29. #=============================================================================
  30. # Copyright 2001-2009 Kitware, Inc.
  31. #
  32. # Distributed under the OSI-approved BSD License (the "License");
  33. # see accompanying file Copyright.txt for details.
  34. #
  35. # This software is distributed WITHOUT ANY WARRANTY; without even the
  36. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  37. # See the License for more information.
  38. #=============================================================================
  39. # (To distributed this file outside of CMake, substitute the full
  40. # License text for the above reference.)
  41. # Construct consitent error messages for use below.
  42. 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.")
  43. SET(VTK_DIR_MESSAGE "VTK not found. Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}")
  44. # Search only if the location is not already known.
  45. IF(NOT VTK_DIR)
  46. # Get the system search path as a list.
  47. IF(UNIX)
  48. STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 "$ENV{PATH}")
  49. ELSE(UNIX)
  50. STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 "$ENV{PATH}")
  51. ENDIF(UNIX)
  52. STRING(REGEX REPLACE "/;" ";" VTK_DIR_SEARCH2 "${VTK_DIR_SEARCH1}")
  53. # Construct a set of paths relative to the system search path.
  54. SET(VTK_DIR_SEARCH "")
  55. FOREACH(dir ${VTK_DIR_SEARCH2})
  56. SET(VTK_DIR_SEARCH ${VTK_DIR_SEARCH}
  57. ${dir}/../lib/vtk-5.4
  58. ${dir}/../lib/vtk-5.2
  59. ${dir}/../lib/vtk-5.1
  60. ${dir}/../lib/vtk-5.0
  61. ${dir}/../lib/vtk
  62. )
  63. ENDFOREACH(dir)
  64. # Old scripts may set these directories in the CMakeCache.txt file.
  65. # They can tell us where to find VTKConfig.cmake.
  66. SET(VTK_DIR_SEARCH_LEGACY "")
  67. IF(VTK_BINARY_PATH AND USE_BUILT_VTK)
  68. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
  69. ENDIF(VTK_BINARY_PATH AND USE_BUILT_VTK)
  70. IF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
  71. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
  72. ${VTK_INSTALL_PATH}/lib/vtk)
  73. ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
  74. #
  75. # Look for an installation or build tree.
  76. #
  77. FIND_PATH(VTK_DIR UseVTK.cmake
  78. # Support legacy cache files.
  79. ${VTK_DIR_SEARCH_LEGACY}
  80. # Look for an environment variable VTK_DIR.
  81. $ENV{VTK_DIR}
  82. # Look in places relative to the system executable search path.
  83. ${VTK_DIR_SEARCH}
  84. # Look in standard UNIX install locations.
  85. /usr/local/lib/vtk
  86. /usr/lib/vtk
  87. # Read from the CMakeSetup registry entries. It is likely that
  88. # VTK will have been recently built.
  89. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  90. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  91. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  92. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  93. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  94. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  95. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  96. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  97. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  98. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  99. # Help the user find it if we cannot.
  100. DOC "The ${VTK_DIR_DESCRIPTION}"
  101. )
  102. ENDIF(NOT VTK_DIR)
  103. # If VTK was found, load the configuration file to get the rest of the
  104. # settings.
  105. IF(VTK_DIR)
  106. # Make sure the VTKConfig.cmake file exists in the directory provided.
  107. IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  108. # We found VTK. Load the settings.
  109. SET(VTK_FOUND 1)
  110. INCLUDE(${VTK_DIR}/VTKConfig.cmake)
  111. ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  112. IF(EXISTS ${VTK_DIR}/UseVTK.cmake)
  113. # We found VTK 4.0 (UseVTK.cmake exists, but not VTKConfig.cmake).
  114. SET(VTK_FOUND 1)
  115. # Load settings for VTK 4.0.
  116. INCLUDE(UseVTKConfig40)
  117. ELSE(EXISTS ${VTK_DIR}/UseVTK.cmake)
  118. # We did not find VTK.
  119. SET(VTK_FOUND 0)
  120. ENDIF(EXISTS ${VTK_DIR}/UseVTK.cmake)
  121. ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  122. ELSE(VTK_DIR)
  123. # We did not find VTK.
  124. SET(VTK_FOUND 0)
  125. ENDIF(VTK_DIR)
  126. #-----------------------------------------------------------------------------
  127. IF(VTK_FOUND)
  128. # Set USE_VTK_FILE for backward-compatability.
  129. SET(USE_VTK_FILE ${VTK_USE_FILE})
  130. ELSE(VTK_FOUND)
  131. # VTK not found, explain to the user how to specify its location.
  132. IF(VTK_FIND_REQUIRED)
  133. MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
  134. ELSE(VTK_FIND_REQUIRED)
  135. IF(NOT VTK_FIND_QUIETLY)
  136. MESSAGE(STATUS ${VTK_DIR_MESSAGE})
  137. ENDIF(NOT VTK_FIND_QUIETLY)
  138. ENDIF(VTK_FIND_REQUIRED)
  139. ENDIF(VTK_FOUND)