vtk-config.cmake 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. #[==[.md
  2. # vtk-config.cmake
  3. This file is used by CMake when finding VTK. It provides the [VTK module
  4. API][] as well as some VTK-specific APIs.
  5. The following variables are provided by this module:
  6. * `VTK_VERSION`: The version of VTK found.
  7. * `VTK_MAJOR_VERSION`: The major version of VTK found.
  8. * `VTK_MINOR_VERSION`: The minor version of VTK found.
  9. * `VTK_BUILD_VERSION`: The build version of VTK found.
  10. * `VTK_AVAILABLE_COMPONENTS`: Components available with VTK.
  11. * `VTK_PREFIX_PATH`: Install prefix for VTK.
  12. * `VTK_LEGACY_REMOVE`: Whether VTK's deprecated APIs are
  13. compiled out or not.
  14. * `VTK_HAS_VTKm`: If VTK provides VTK-m.
  15. * `VTK_OPENGL_HAS_EGL`: If VTK::opengl uses EGL. Only provided if the
  16. `VTK::opengl` target exists.
  17. * `VTK_PYTHON_VERSION`: The major version of Python used by VTK. Empty if
  18. Python support is not available.
  19. * `VTK_WRAP_PYTHON`: If VTK itself provides Python wrapping. If so, the
  20. Python parts of the module API are available.
  21. * `VTK_WRAP_JAVA`: If VTK itself provides Java wrapping. If so, the
  22. Java parts of the module API are available.
  23. * `VTK_PYTHONPATH`: Where VTK's Python modules live inside the install
  24. prefix. Unset if Python is not available.
  25. * `VTK_LIBRARIES`: The list of modules specified by `COMPONENTS` and
  26. `OPTIONAL_COMPONENTS`. However, if no components are specified, all
  27. available components are added to this variable. This may be used in
  28. `MODULES` arguments in the API (e.g., `vtk_module_autoinit`). All modules
  29. are also targets and may be linked to using `target_link_libraries`.
  30. * `VTK_AUTOINIT_INCLUDE`: The header to include for access to VTK's autoinit
  31. support.
  32. For more information about the Python in use by VTK, the `VTK_PYTHON_VERSION`
  33. variable may be used to query the `find_package(Python)` that VTK performs
  34. internally (note that the `Python` component must be found to guarantee that
  35. this happens). For example, the following information would be useful:
  36. - the `Python${VTK_PYTHON_VERSION}_VERSION` variable; and
  37. - the `Python${VTK_PYTHON_VERSION}::Python` target.
  38. See [FindPython2][] and [FindPython3][] documentation for all of the available
  39. data.
  40. [FindPython2]: https://cmake.org/cmake/help/v3.13/module/FindPython2.html
  41. [FindPython3]: https://cmake.org/cmake/help/v3.13/module/FindPython3.html
  42. [VTK module API]: TODO: Link to hosted documentation.
  43. #]==]
  44. cmake_policy(PUSH)
  45. cmake_policy(VERSION 3.8...3.12)
  46. set(_vtk_temp_variables)
  47. set(_vtk_real_components)
  48. foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
  49. if (_vtk_component MATCHES "^vtk" AND
  50. NOT _vtk_component STREQUAL "vtksys" AND
  51. NOT _vtk_component STREQUAL "vtkjava")
  52. string(SUBSTRING "${_vtk_component}" 3 -1 _vtk_actual_component)
  53. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION)
  54. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  55. message(DEPRECATION
  56. "The new name for the '${_vtk_component}' component is "
  57. "'${_vtk_actual_component}'")
  58. endif ()
  59. elseif (${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 8.90)
  60. # Ignore for compatibility.
  61. else ()
  62. message(FATAL_ERROR
  63. "The new name for the '${_vtk_component}' component is "
  64. "'${_vtk_actual_component}'. By requesting at least version 8.90, the "
  65. "new component names are now required.")
  66. endif ()
  67. list(APPEND _vtk_real_components
  68. "${_vtk_actual_component}")
  69. list(APPEND _vtk_temp_variables
  70. "${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_vtk_actual_component}")
  71. set("${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_vtk_actual_component}"
  72. "${${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_vtk_component}}")
  73. unset(_vtk_actual_component)
  74. else ()
  75. list(APPEND _vtk_real_components
  76. "${_vtk_component}")
  77. endif ()
  78. endforeach ()
  79. unset(_vtk_component)
  80. set("${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS"
  81. ${_vtk_real_components})
  82. unset(_vtk_real_components)
  83. set("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_MODULE_PATH_save" "${CMAKE_MODULE_PATH}")
  84. list(INSERT CMAKE_MODULE_PATH 0
  85. "${CMAKE_CURRENT_LIST_DIR}")
  86. set("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save" "${CMAKE_PREFIX_PATH}")
  87. include("${CMAKE_CURRENT_LIST_DIR}/vtk-prefix.cmake")
  88. set("${CMAKE_FIND_PACKAGE_NAME}_PREFIX_PATH"
  89. "${_vtk_module_import_prefix}")
  90. unset(_vtk_module_import_prefix)
  91. list(INSERT CMAKE_PREFIX_PATH 0
  92. "${${CMAKE_FIND_PACKAGE_NAME}_PREFIX_PATH}")
  93. set("${CMAKE_FIND_PACKAGE_NAME}_VERSION" "9.0.1")
  94. set("${CMAKE_FIND_PACKAGE_NAME}_MAJOR_VERSION" "9")
  95. set("${CMAKE_FIND_PACKAGE_NAME}_MINOR_VERSION" "0")
  96. set("${CMAKE_FIND_PACKAGE_NAME}_BUILD_VERSION" "1")
  97. set("${CMAKE_FIND_PACKAGE_NAME}_LEGACY_REMOVE" "OFF")
  98. set("${CMAKE_FIND_PACKAGE_NAME}_AUTOINIT_INCLUDE" "\"vtkAutoInit.h\"")
  99. set("${CMAKE_FIND_PACKAGE_NAME}_AVAILABLE_COMPONENTS" "WrappingTools;ViewsQt;ViewsInfovis;CommonColor;ViewsContext2D;loguru;TestingRendering;TestingCore;vtksys;RenderingQt;RenderingVolumeOpenGL2;RenderingOpenGL2;glew;opengl;RenderingLabel;octree;RenderingLOD;RenderingImage;IOTecplotTable;IOSegY;IOParallelXML;IOParallel;jsoncpp;IOPLY;IOOggTheora;theora;ogg;IOMotionFX;pegtl;IOLSDyna;IOInfovis;libxml2;zlib;IOImport;IOGeometry;IOVideo;IOMovie;IOExportPDF;libharu;IOExportGL2PS;RenderingGL2PSOpenGL2;gl2ps;png;IOExport;RenderingVtkJS;RenderingSceneGraph;IOEnSight;IOCityGML;pugixml;IOAsynchronous;InteractionImage;ImagingStencil;ImagingStatistics;ImagingMorphological;ImagingMath;GUISupportQtSQL;IOSQL;sqlite;GUISupportQt;GeovisCore;libproj;InfovisLayout;ViewsCore;InteractionWidgets;RenderingVolume;RenderingAnnotation;ImagingHybrid;ImagingColor;InteractionStyle;FiltersTopology;FiltersSelection;FiltersSMP;FiltersProgrammable;FiltersPoints;FiltersVerdict;verdict;FiltersParallelImaging;FiltersImaging;ImagingGeneral;FiltersHyperTree;FiltersGeneric;FiltersFlowPaths;FiltersAMR;FiltersParallel;FiltersTexture;FiltersModeling;FiltersHybrid;RenderingUI;DomainsChemistry;ChartsCore;InfovisCore;FiltersExtraction;ParallelDIY;diy2;IOXML;IOXMLParser;expat;ParallelCore;IOLegacy;IOCore;doubleconversion;lz4;lzma;utf8;FiltersStatistics;eigen;ImagingFourier;ImagingSources;IOImage;DICOMParser;jpeg;metaio;tiff;RenderingContext2D;RenderingFreeType;freetype;kwiml;RenderingCore;FiltersSources;ImagingCore;FiltersGeometry;FiltersGeneral;CommonComputationalGeometry;FiltersCore;CommonExecutionModel;CommonDataModel;CommonSystem;CommonMisc;CommonTransforms;CommonMath;CommonCore")
  100. unset("${CMAKE_FIND_PACKAGE_NAME}_FOUND")
  101. set("${CMAKE_FIND_PACKAGE_NAME}_HAS_VTKm" "OFF")
  102. if (${CMAKE_FIND_PACKAGE_NAME}_HAS_VTKm)
  103. find_package(VTKm
  104. PATHS "${CMAKE_CURRENT_LIST_DIR}/vtkm"
  105. NO_DEFAULT_PATH)
  106. if (NOT VTKm_FOUND)
  107. set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 0)
  108. endif ()
  109. endif ()
  110. include("${CMAKE_CURRENT_LIST_DIR}/vtkCMakeBackports.cmake")
  111. include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-targets.cmake")
  112. include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-vtk-module-properties.cmake")
  113. include("${CMAKE_CURRENT_LIST_DIR}/vtk-find-package-helpers.cmake" OPTIONAL)
  114. include("${CMAKE_CURRENT_LIST_DIR}/${CMAKE_FIND_PACKAGE_NAME}-vtk-module-find-packages.cmake")
  115. if (TARGET VTK::opengl)
  116. set(VTK_OPENGL_HAS_EGL "OFF")
  117. endif ()
  118. include("${CMAKE_CURRENT_LIST_DIR}/vtkModule.cmake")
  119. include("${CMAKE_CURRENT_LIST_DIR}/vtkEncodeString.cmake")
  120. include("${CMAKE_CURRENT_LIST_DIR}/vtkHashSource.cmake")
  121. include("${CMAKE_CURRENT_LIST_DIR}/vtkObjectFactory.cmake")
  122. include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleJson.cmake")
  123. set("${CMAKE_FIND_PACKAGE_NAME}_PYTHON_VERSION" "")
  124. set("${CMAKE_FIND_PACKAGE_NAME}_WRAP_PYTHON" "OFF")
  125. if (${CMAKE_FIND_PACKAGE_NAME}_WRAP_PYTHON)
  126. include("${CMAKE_CURRENT_LIST_DIR}/VTKPython-targets.cmake")
  127. include("${CMAKE_CURRENT_LIST_DIR}/vtkmodules-vtk-python-module-properties.cmake")
  128. include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleWrapPython.cmake")
  129. set("${CMAKE_FIND_PACKAGE_NAME}_PYTHONPATH" "")
  130. endif ()
  131. set("${CMAKE_FIND_PACKAGE_NAME}_WRAP_JAVA" "OFF")
  132. if (${CMAKE_FIND_PACKAGE_NAME}_WRAP_JAVA)
  133. include("${CMAKE_CURRENT_LIST_DIR}/vtkModuleWrapJava.cmake")
  134. if () # VTK_JAVA_JOGL_COMPONENT
  135. set(_vtk_find_jogl_args)
  136. if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
  137. list(APPEND _vtk_find_jogl_args QUIET)
  138. endif ()
  139. find_package(JOGL ${_vtk_find_jogl_args})
  140. unset(_vtk_find_jogl_args)
  141. if (JOGL_FOUND)
  142. include("${CMAKE_CURRENT_LIST_DIR}/VTKJava-targets.cmake")
  143. set("${CMAKE_FIND_PACKAGE_NAME}_vtkjava_FOUND" 1)
  144. else ()
  145. set("${CMAKE_FIND_PACKAGE_NAME}_vtkjava_FOUND" 0)
  146. set("${CMAKE_FIND_PACKAGE_NAME}_vtkjava_NOT_FOUND_MESSAGE"
  147. "JOGL was not found")
  148. endif ()
  149. endif ()
  150. endif ()
  151. set(_vtk_components_to_check)
  152. foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
  153. if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
  154. # It was already not-found (likely due to `find-package` failures).
  155. elseif (TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}")
  156. list(APPEND _vtk_components_to_check
  157. "${_vtk_component}")
  158. else ()
  159. set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 0)
  160. list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_NOT_FOUND_MESSAGE"
  161. "The ${_vtk_component} component is not available.")
  162. endif ()
  163. endforeach ()
  164. unset(_vtk_component)
  165. while (_vtk_components_to_check)
  166. list(GET _vtk_components_to_check 0 _vtk_component)
  167. list(REMOVE_AT _vtk_components_to_check 0)
  168. if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
  169. # We've already made a determiniation.
  170. continue ()
  171. endif ()
  172. get_property(_vtk_public_dependencies
  173. TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}"
  174. PROPERTY "INTERFACE_vtk_module_depends")
  175. get_property(_vtk_private_dependencies
  176. TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}"
  177. PROPERTY "INTERFACE_vtk_module_private_depends")
  178. get_property(_vtk_optional_dependencies
  179. TARGET "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}"
  180. PROPERTY "INTERFACE_vtk_module_optional_depends")
  181. set(_vtk_dependencies
  182. ${_vtk_public_dependencies}
  183. ${_vtk_private_dependencies})
  184. foreach (_vtk_optional_dependency IN LISTS _vtk_optional_dependencies)
  185. if (TARGET "${_vtk_optional_dependency}")
  186. list(APPEND _vtk_dependencies
  187. "${_vtk_optional_dependency}")
  188. endif ()
  189. endforeach ()
  190. unset(_vtk_public_dependencies)
  191. unset(_vtk_private_dependencies)
  192. unset(_vtk_optional_dependency)
  193. unset(_vtk_optional_dependencies)
  194. string(REPLACE "${CMAKE_FIND_PACKAGE_NAME}::" "" _vtk_dependencies "${_vtk_dependencies}")
  195. set(_vtk_all_dependencies_checked TRUE)
  196. foreach (_vtk_dependency IN LISTS _vtk_dependencies)
  197. if (DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_dependency}_FOUND")
  198. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_${_vtk_dependency}_FOUND)
  199. set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 0)
  200. list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_NOT_FOUND_MESSAGE"
  201. "Failed to find the ${_vtk_dependency} component.")
  202. endif ()
  203. else ()
  204. # Check its dependencies.
  205. list(APPEND _vtk_components_to_check
  206. "${_vtk_dependency}")
  207. set(_vtk_all_found FALSE)
  208. endif ()
  209. endforeach ()
  210. if (NOT DEFINED "${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND")
  211. if (_vtk_all_dependencies_checked)
  212. set("${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND" 1)
  213. else ()
  214. list(APPEND _vtk_components_to_check
  215. "${_vtk_component}")
  216. endif ()
  217. endif ()
  218. unset(_vtk_all_dependencies_checked)
  219. unset(_vtk_dependency)
  220. unset(_vtk_dependencies)
  221. endwhile ()
  222. unset(_vtk_component)
  223. unset(_vtk_components_to_check)
  224. set(_vtk_missing_components)
  225. foreach (_vtk_component IN LISTS "${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")
  226. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_${_vtk_component}_FOUND AND ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_${_vtk_component})
  227. list(APPEND _vtk_missing_components
  228. "${_vtk_component}")
  229. endif ()
  230. endforeach ()
  231. if (_vtk_missing_components)
  232. list(REMOVE_DUPLICATES _vtk_missing_components)
  233. list(SORT _vtk_missing_components)
  234. string(REPLACE ";" ", " _vtk_missing_components "${_vtk_missing_components}")
  235. set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 0)
  236. set("${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE"
  237. "Could not find the ${CMAKE_FIND_PACKAGE_NAME} package with the following required components: ${_vtk_missing_components}.")
  238. endif ()
  239. unset(_vtk_missing_components)
  240. set("${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES")
  241. if (NOT DEFINED "${CMAKE_FIND_PACKAGE_NAME}_FOUND")
  242. # If nothing went wrong, we've successfully found the package.
  243. set("${CMAKE_FIND_PACKAGE_NAME}_FOUND" 1)
  244. set(_vtk_found_components
  245. ${${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS})
  246. if (NOT _vtk_found_components)
  247. set(_vtk_found_components
  248. ${${CMAKE_FIND_PACKAGE_NAME}_AVAILABLE_COMPONENTS})
  249. endif ()
  250. list(REMOVE_ITEM _vtk_found_components
  251. # This component needs to always be requested explicitly (it is not a
  252. # module).
  253. vtkjava)
  254. # Build the `_LIBRARIES` variable.
  255. foreach (_vtk_component IN LISTS _vtk_found_components)
  256. list(APPEND "${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES"
  257. "${CMAKE_FIND_PACKAGE_NAME}::${_vtk_component}")
  258. endforeach ()
  259. unset(_vtk_component)
  260. unset(_vtk_found_components)
  261. endif ()
  262. set(CMAKE_PREFIX_PATH "${${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save}")
  263. unset("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_PREFIX_PATH_save")
  264. set(CMAKE_MODULE_PATH "${${CMAKE_FIND_PACKAGE_NAME}_CMAKE_MODULE_PATH_save}")
  265. unset("${CMAKE_FIND_PACKAGE_NAME}_CMAKE_MODULE_PATH_save")
  266. foreach (_vtk_temp_variable IN LISTS _vtk_temp_variables)
  267. unset("${_vtk_temp_variable}")
  268. endforeach ()
  269. unset(_vtk_temp_variable)
  270. unset(_vtk_temp_variables)
  271. # Compatibility with old code.
  272. if (NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION)
  273. set(VTK_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/vtk-use-file-deprecated.cmake")
  274. elseif (${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 8.90)
  275. set(VTK_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/vtk-use-file-compat.cmake")
  276. else ()
  277. set(VTK_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/vtk-use-file-error.cmake")
  278. endif ()
  279. cmake_policy(POP)