FindVTK.cmake 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #
  2. # Find a VTK installation or build tree.
  3. #
  4. # The following variables are set if VTK is found. If VTK is not
  5. # found, VTK_FOUND is set to false.
  6. #
  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, ...).
  16. # VTK_SETTINGS - List of all CMake variable settings provided by
  17. # the version of VTK that was found. This list
  18. # may include settings that are not listed here.
  19. #
  20. # The following cache entries must be set by the user to locate VTK:
  21. #
  22. # VTK_DIR - The directory containing VTKConfig.cmake. This is either
  23. # the root of the build tree, or the lib/vtk
  24. # directory. This is the only cache entry.
  25. #
  26. # The following variables are set for backward compatability and
  27. # should not be used in new code:
  28. #
  29. # USE_VTK_FILE - The full path to the UseVTK.cmake file. This is provided
  30. # for backward compatability. Use VTK_USE_FILE instead.
  31. #
  32. # Construct consitent error messages for use below.
  33. 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.")
  34. SET(VTK_DIR_MESSAGE "VTK not found. Set VTK_DIR to the ${VTK_DIR_DESCRIPTION}")
  35. # Search only if the location is not already known.
  36. IF(NOT VTK_DIR)
  37. # Get the system search path as a list.
  38. IF(UNIX)
  39. STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 $ENV{PATH})
  40. ELSE(UNIX)
  41. STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 $ENV{PATH})
  42. ENDIF(UNIX)
  43. 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")
  48. ENDFOREACH(dir)
  49. # Old scripts may set these directories in the CMakeCache.txt file.
  50. # They can tell us where to find VTKConfig.cmake.
  51. SET(VTK_DIR_SEARCH_LEGACY "")
  52. IF(VTK_BINARY_PATH AND USE_BUILT_VTK)
  53. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
  54. ENDIF(VTK_BINARY_PATH AND USE_BUILT_VTK)
  55. IF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
  56. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
  57. ${VTK_INSTALL_PATH}/lib/vtk)
  58. ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
  59. #
  60. # Look for an installation or build tree.
  61. #
  62. FIND_PATH(VTK_DIR UseVTK.cmake
  63. # Support legacy cache files.
  64. ${VTK_DIR_SEARCH_LEGACY}
  65. # Look in places relative to the system executable search path.
  66. ${VTK_DIR_SEARCH}
  67. # Look in standard UNIX install locations.
  68. /usr/local/lib/vtk
  69. /usr/lib/vtk
  70. # Read from the CMakeSetup registry entries. It is likely that
  71. # VTK will have been recently built.
  72. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  73. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  74. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  75. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  76. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  77. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  78. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  79. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  80. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  81. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  82. # Help the user find it if we cannot.
  83. DOC "The ${VTK_DIR_DESCRIPTION}"
  84. )
  85. ENDIF(NOT VTK_DIR)
  86. # If VTK was found, load the configuration file to get the rest of the
  87. # settings.
  88. IF(VTK_DIR)
  89. # Make sure the VTKConfig.cmake file exists in the directory provided.
  90. IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  91. # We found VTK. Load the settings.
  92. SET(VTK_FOUND 1)
  93. INCLUDE(${VTK_DIR}/VTKConfig.cmake)
  94. ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  95. IF(EXISTS ${VTK_DIR}/UseVTK.cmake)
  96. # We found VTK 4.0 (UseVTK.cmake exists, but not VTKConfig.cmake).
  97. SET(VTK_FOUND 1)
  98. # Load settings for VTK 4.0.
  99. INCLUDE(${CMAKE_ROOT}/Modules/UseVTKConfig40.cmake)
  100. ELSE(EXISTS ${VTK_DIR}/UseVTK.cmake)
  101. # We did not find VTK.
  102. SET(VTK_FOUND 0)
  103. ENDIF(EXISTS ${VTK_DIR}/UseVTK.cmake)
  104. ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  105. ELSE(VTK_DIR)
  106. # We did not find VTK.
  107. SET(VTK_FOUND 0)
  108. ENDIF(VTK_DIR)
  109. #-----------------------------------------------------------------------------
  110. IF(VTK_FOUND)
  111. # Set USE_VTK_FILE for backward-compatability.
  112. SET(USE_VTK_FILE ${VTK_USE_FILE})
  113. ELSE(VTK_FOUND)
  114. # VTK not found, explain to the user how to specify its location.
  115. IF(NOT VTK_FIND_QUIETLY)
  116. MESSAGE(${VTK_DIR_MESSAGE})
  117. ENDIF(NOT VTK_FIND_QUIETLY)
  118. ENDIF(VTK_FOUND)