FindVTK.cmake 4.6 KB

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