1if(NOT WITH_VTK OR ANDROID OR IOS) 2 return() 3endif() 4 5# VTK 6.x components 6find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE) 7 8# VTK 5.x components 9if(NOT VTK_FOUND) 10 find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE) 11endif() 12 13if(NOT VTK_FOUND) 14 set(HAVE_VTK OFF) 15 message(STATUS "VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file") 16 return() 17endif() 18 19# Don't support ealier VTKs 20if(${VTK_VERSION} VERSION_LESS "5.8.0") 21 message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}") 22 return() 23endif() 24 25# Different Qt versions can't be linked together 26if(HAVE_QT5 AND ${VTK_VERSION} VERSION_LESS "6.0.0") 27 if(VTK_USE_QT) 28 message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4") 29 endif() 30endif() 31 32# Different Qt versions can't be linked together. VTK 6.0.0 doesn't provide a way to get Qt version it was linked with 33if(HAVE_QT5 AND ${VTK_VERSION} VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK) 34 message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4") 35 message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake") 36 return() 37endif() 38 39# Different Qt versions can't be linked together 40if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "") 41 if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4") 42 message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4") 43 return() 44 endif() 45 46 if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5") 47 message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5") 48 return() 49 endif() 50endif() 51 52set(HAVE_VTK ON) 53message(STATUS "Found VTK ver. ${VTK_VERSION} (usefile: ${VTK_USE_FILE})") 54