FindVTK.cmake 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 - the full path and location of the UseVTK.cmake file
  13. # ONLY SET if ONE of the USE_BUILT_VTK or
  14. # USE_INSTALLED_VTK is set to ON.
  15. #
  16. #
  17. # Look for a binary tree (built from source)
  18. #
  19. FIND_PATH(VTK_BINARY_PATH UseVTK.cmake
  20. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  21. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  22. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  23. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  24. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  25. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  26. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  27. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  28. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  29. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  30. ../VTKBIN
  31. ../vtkbin
  32. VTKBIN
  33. vtkbin
  34. $ENV{HOME}/VTKBIN
  35. $ENV{HOME}/vtkbin
  36. )
  37. #
  38. # Look for an installed tree
  39. #
  40. FIND_PATH(VTK_INSTALL_PATH include/vtk/UseVTK.cmake
  41. /usr/local
  42. /usr
  43. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\Nightly]
  44. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\43]
  45. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\42]
  46. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\41]
  47. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\40]
  48. )
  49. #
  50. # If we found a built tree, USE_BUILT_VTK allows the user to
  51. # use it or not.
  52. #
  53. # Important: it *has* to be set to OFF first in order to allow
  54. # the user to change the VTK_BINARY_PATH value *before* the USE_VTK_FILE
  55. # is set (and the cache created).
  56. #
  57. # For example, CMake could have picked-up the wrong VTK binary path, and if
  58. # the related VTK cache was immediately loaded there would not be any way
  59. # to overwrite these cache values (even by changing the binary path or
  60. # USE_VTK_FILE).
  61. #
  62. IF (VTK_BINARY_PATH)
  63. SET (USE_BUILT_VTK 0 CACHE BOOL
  64. "Use a built (versus installed) version of VTK. Be sure VTK_BINARY_PATH is correct before setting it to ON.")
  65. ENDIF (VTK_BINARY_PATH)
  66. #
  67. # If we found an installed tree, USE_INSTALLED_VTK allows the user to
  68. # use it or not.
  69. #
  70. # Important: it *has* to be set to OFF first in order to allow
  71. # the user to change the VTK_INSTALL_PATH value before the USE_VTK_FILE
  72. # is set (and the cache created).
  73. #
  74. # For example, you might have simultaneously installed different major
  75. # versions like VTK 3.2, 4.0, 5.1, etc.
  76. #
  77. # Moreover, USE_INSTALLED_VTK has to be OFF since USE_BUILT_VTK has to be OFF
  78. # too (see above). If USE_INSTALLED_VTK was ON by default, then USE_VTK_FILE
  79. # would be set immediately (since one of them is ON) in favor of the
  80. # installed tree.
  81. #
  82. IF (VTK_INSTALL_PATH)
  83. SET (USE_INSTALLED_VTK 0 CACHE BOOL
  84. "Use an installed (versus built from source) version of VTK. Be sure VTK_INSTALL_PATH is correct before setting it to ON.")
  85. ENDIF (VTK_INSTALL_PATH)
  86. #
  87. # Set the USE_VTK_FILE only if one of USE_BUILT_VTK or USE_INSTALLED_VTK
  88. # is ON, i.e. if the user has decided if he wants to use either the built
  89. # or the installed VTK. Even if only one of the VTK flavor was found,
  90. # this also enable the user to change the path to his VTK (in case the
  91. # wrong installed or built VTK was automatically found).
  92. #
  93. # Once this decision has been made, there is no way to go back except by
  94. # erasing the cache. Mark these useless vars as ADVANCED to reflect this.
  95. #
  96. IF (USE_BUILT_VTK)
  97. IF (NOT USE_INSTALLED_VTK)
  98. FIND_FILE(USE_VTK_FILE UseVTK.cmake ${VTK_BINARY_PATH})
  99. MARK_AS_ADVANCED(
  100. USE_BUILT_VTK
  101. USE_INSTALLED_VTK
  102. USE_VTK_FILE
  103. VTK_INSTALL_PATH
  104. )
  105. ENDIF (NOT USE_INSTALLED_VTK)
  106. ELSE (USE_BUILT_VTK)
  107. IF (USE_INSTALLED_VTK)
  108. SET (USE_VTK_FILE ${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake)
  109. MARK_AS_ADVANCED(
  110. USE_BUILT_VTK
  111. USE_INSTALLED_VTK
  112. USE_VTK_FILE
  113. VTK_BINARY_PATH
  114. )
  115. ENDIF (USE_INSTALLED_VTK)
  116. ENDIF (USE_BUILT_VTK)
  117. # Note:
  118. #
  119. # If you use that module then you are probably relying on VTK to be found
  120. # on your system. As said before, it might be found as different flavours:
  121. # installed VTK, or (multiple) built VTK. Moreover, even if it is found
  122. # automatically, CMake might have picked the wrong path/version.
  123. #
  124. # Here is the CMake code you might probably want to use to work hand-in-hand
  125. # with that module:
  126. #
  127. # INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
  128. #
  129. # IF (USE_VTK_FILE)
  130. # INCLUDE (${USE_VTK_FILE})
  131. # ELSE (USE_VTK_FILE)
  132. # MESSAGE("Warning. This project is supposed to work with VTK, which might be found on your system as different flavours: installed VTK, or (multiple) built VTK. Please, make sure that the VTK_INSTALL_PATH or VTK_BINARY_PATH setting reflect which VTK you are planning to use, then set one of the USE_INSTALLED_VTK or USE_BUILT_VTK to ON.")
  133. # SET (CAN_BUILD 0)
  134. # ENDIF (USE_VTK_FILE)