FindVTK.cmake 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #
  2. # Find a VTK installation or build tree.
  3. #
  4. # When VTK is found, the VTKConfig.cmake file is sourced to setup the
  5. # location and configuration of VTK. Please read this file, or
  6. # VTKConfig.cmake.in from the VTK source tree for the full list of
  7. # definitions. Of particular interest is
  8. #
  9. # VTK_USE_FILE - A CMake source file that can be included
  10. # to set the include directories, library
  11. # directories, and preprocessor macros.
  12. #
  13. # In addition to the variables read from VTKConfig.cmake, this find
  14. # module also defines
  15. #
  16. # VTK_DIR - The directory containing VTKConfig.cmake. This is either
  17. # the root of the build tree, or the lib/vtk
  18. # directory. This is the only cache entry.
  19. #
  20. # VTK_FOUND - Whether VTK was found. If this is true, VTK_DIR is okay.
  21. #
  22. # USE_VTK_FILE - The full path to the UseVTK.cmake file. This is provided
  23. # for backward compatability. Use VTK_USE_FILE instead.
  24. #
  25. # Construct consitent error messages for use below.
  26. SET(VTK_DIR_DESCRIPTION "directory containing VTKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/vtk for an installation.")
  27. SET(VTK_DIR_MESSAGE "VTK not found. Set VTK_DIR to the ${VTK_DIR_DESCRIPTION}")
  28. # Search only if the location is not already known.
  29. IF(NOT VTK_DIR)
  30. # Get the system search path as a list.
  31. IF(UNIX)
  32. STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 $ENV{PATH})
  33. ELSE(UNIX)
  34. STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 $ENV{PATH})
  35. ENDIF(UNIX)
  36. STRING(REGEX REPLACE "/;" ";" VTK_DIR_SEARCH2 ${VTK_DIR_SEARCH1})
  37. # Construct a set of paths relative to the system search path.
  38. SET(VTK_DIR_SEARCH "")
  39. FOREACH(dir ${VTK_DIR_SEARCH2})
  40. SET(VTK_DIR_SEARCH ${VTK_DIR_SEARCH} "${dir}/../lib/vtk")
  41. ENDFOREACH(dir)
  42. # Old scripts may set these directories in the CMakeCache.txt file.
  43. # They can tell us where to find VTKConfig.cmake.
  44. SET(VTK_DIR_SEARCH_LEGACY "")
  45. IF(VTK_BINARY_PATH)
  46. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
  47. ENDIF(VTK_BINARY_PATH)
  48. IF(VTK_INSTALL_PATH)
  49. SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
  50. ${VTK_INSTALL_PATH}/lib/vtk)
  51. ENDIF(VTK_INSTALL_PATH)
  52. #
  53. # Look for an installation or build tree.
  54. #
  55. FIND_PATH(VTK_DIR VTKConfig.cmake
  56. # Support legacy cache files.
  57. ${VTK_DIR_SEARCH_LEGACY}
  58. # Look in places relative to the system executable search path.
  59. ${VTK_DIR_SEARCH}
  60. # Look in standard UNIX install locations.
  61. /usr/local/lib/vtk
  62. /usr/lib/vtk
  63. # Read from the CMakeSetup registry entries. It is likely that
  64. # VTK will have been recently built.
  65. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  66. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  67. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  68. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  69. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  70. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  71. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  72. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  73. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  74. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  75. # Help the user find it if we cannot.
  76. DOC "The ${VTK_DIR_DESCRIPTION}"
  77. )
  78. ENDIF(NOT VTK_DIR)
  79. # If VTK was found, load the configuration file to get the rest of the
  80. # settings.
  81. IF(VTK_DIR)
  82. # Make sure the VTKConfig.cmake file exists in the directory provided.
  83. IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  84. # We found VTK. Load the settings.
  85. SET(VTK_FOUND 1)
  86. INCLUDE(${VTK_DIR}/VTKConfig.cmake)
  87. # Set USE_VTK_FILE for backward-compatability.
  88. SET(USE_VTK_FILE ${VTK_USE_FILE})
  89. ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  90. # We did not find VTK.
  91. SET(VTK_FOUND 0)
  92. ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
  93. ELSE(VTK_DIR)
  94. # We did not find VTK.
  95. SET(VTK_FOUND 0)
  96. ENDIF(VTK_DIR)
  97. # If it was not found, explain to the user how to specify its
  98. # location.
  99. IF (NOT VTK_FOUND)
  100. IF (NOT VTK_FIND_QUIETLY)
  101. MESSAGE(${VTK_DIR_MESSAGE})
  102. ENDIF (NOT VTK_FIND_QUIETLY)
  103. ENDIF (NOT VTK_FOUND)