FindVTK.cmake 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #
  2. # Find the native VTK includes and library
  3. #
  4. # This module defines:
  5. #
  6. # VTK_INSTALL_PATH - Where is the installed version of VTK.
  7. # USE_BUILT_VTK - Should a built-from-source version of VTK be used.
  8. #
  9. # VTK_BINARY_PATH - Where is (one of) the binary tree(s).
  10. # USE_INSTALLED_VTK - Should an installed version of VTK be used
  11. #
  12. # USE_VTK_FILE - (internal)
  13. # Full path and location to the UseVTK.cmake file.
  14. # This value changes each time USE_BUILT_VTK or
  15. # USE_INSTALLED_VTK is modified, and only if ONE of
  16. # these setting is set to ON.
  17. #
  18. # If VTK is not found, an error is displayed unless VTK_FIND_QUIETLY
  19. # is on.
  20. #
  21. #
  22. # Look for a binary tree (built from source)
  23. #
  24. FIND_PATH(VTK_BINARY_PATH UseVTK.cmake
  25. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  26. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  27. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  28. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  29. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  30. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  31. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  32. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  33. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  34. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  35. ../VTKBIN
  36. ../vtkbin
  37. VTKBIN
  38. vtkbin
  39. $ENV{HOME}/VTKBIN
  40. $ENV{HOME}/vtkbin
  41. )
  42. #
  43. # If we found a built tree, USE_BUILT_VTK allows the user to
  44. # use it or not. Defaults to ON.
  45. #
  46. IF (VTK_BINARY_PATH)
  47. SET (USE_BUILT_VTK 1 CACHE BOOL
  48. "Use a built (versus installed) version of VTK. Be sure that VTK_BINARY_PATH is correct.")
  49. ENDIF (VTK_BINARY_PATH)
  50. #
  51. # Look for an installed tree
  52. #
  53. FIND_PATH(VTK_INSTALL_PATH include/vtk/UseVTK.cmake
  54. /usr/local
  55. /usr
  56. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\Nightly]
  57. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\43]
  58. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\42]
  59. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\41]
  60. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\40]
  61. )
  62. #
  63. # If we found an installed tree, USE_INSTALLED_VTK allows the user to
  64. # use it or not.
  65. #
  66. # Defaults to OFF if a built tree was found before (see above), ON otherwise.
  67. #
  68. IF (VTK_INSTALL_PATH)
  69. IF (USE_BUILT_VTK)
  70. SET (USE_INSTALLED_VTK 0 CACHE BOOL
  71. "Use an installed (versus built from source) version of VTK. Be sure that VTK_INSTALL_PATH is correct.")
  72. ELSE (USE_BUILT_VTK)
  73. SET (USE_INSTALLED_VTK 1 CACHE BOOL
  74. "Use an installed (versus built from source) version of VTK. Be sure that VTK_INSTALL_PATH is correct.")
  75. ENDIF (USE_BUILT_VTK)
  76. ENDIF (VTK_INSTALL_PATH)
  77. #
  78. # Set the USE_VTK_FILE only if one of USE_BUILT_VTK or USE_INSTALLED_VTK
  79. # is ON.
  80. #
  81. IF (USE_BUILT_VTK)
  82. IF (NOT USE_INSTALLED_VTK)
  83. IF (EXISTS "${VTK_BINARY_PATH}/UseVTK.cmake")
  84. SET (USE_VTK_FILE "${VTK_BINARY_PATH}/UseVTK.cmake")
  85. ENDIF (EXISTS "${VTK_BINARY_PATH}/UseVTK.cmake")
  86. ENDIF (NOT USE_INSTALLED_VTK)
  87. ELSE (USE_BUILT_VTK)
  88. IF (USE_INSTALLED_VTK)
  89. IF (EXISTS "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
  90. SET (USE_VTK_FILE "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
  91. ENDIF (EXISTS "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
  92. ENDIF (USE_INSTALLED_VTK)
  93. ENDIF (USE_BUILT_VTK)
  94. #
  95. # Display a warning if both settings are set to ON.
  96. # Otherwise display a warning if VTK was not found.
  97. #
  98. IF (USE_BUILT_VTK AND USE_INSTALLED_VTK)
  99. MESSAGE ("Warning. Please make sure that only ONE of the USE_INSTALLED_VTK or USE_BUILT_VTK setting is set to ON.")
  100. ELSE (USE_BUILT_VTK AND USE_INSTALLED_VTK)
  101. IF (NOT USE_VTK_FILE)
  102. IF (NOT VTK_FIND_QUIETLY)
  103. MESSAGE ("Warning. VTK might be found on your system as different flavours: installed VTK or built VTK. Please make sure that the VTK_INSTALL_PATH or VTK_BINARY_PATH setting reflects which VTK you are planning to use, then set ONE of the USE_INSTALLED_VTK or USE_BUILT_VTK setting to ON.")
  104. ENDIF (NOT VTK_FIND_QUIETLY)
  105. ENDIF (NOT USE_VTK_FILE)
  106. ENDIF (USE_BUILT_VTK AND USE_INSTALLED_VTK)
  107. # Note:
  108. #
  109. # If you use that module then you are probably relying on VTK to be found
  110. # on your system. Here is the CMake code you might probably want to use to
  111. # work hand-in-hand with that module (in that example CAN_BUILD is a var
  112. # that is set to 0 if your project can not be build):
  113. #
  114. # INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
  115. #
  116. # IF (USE_VTK_FILE)
  117. # INCLUDE (${USE_VTK_FILE})
  118. # ELSE (USE_VTK_FILE)
  119. # SET (CAN_BUILD 0)
  120. # ENDIF (USE_VTK_FILE)