Merge pull request #10143 from pengli:ocl4dnn
[platform/upstream/opencv.git] / cmake / OpenCVDetectVTK.cmake
1 if(NOT WITH_VTK)
2   return()
3 endif()
4
5 # VTK 6.x components
6 find_package(VTK QUIET COMPONENTS vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
7 IF(VTK_FOUND)
8   IF(VTK_RENDERING_BACKEND) #in vtk 7, the rendering backend is exported as a var.
9       find_package(VTK QUIET COMPONENTS vtkRendering${VTK_RENDERING_BACKEND} vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport vtkIOGeometry NO_MODULE)
10   ELSE(VTK_RENDERING_BACKEND)
11       find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
12   ENDIF(VTK_RENDERING_BACKEND)
13 ENDIF(VTK_FOUND)
14
15 # VTK 5.x components
16 if(NOT VTK_FOUND)
17   find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE)
18 endif()
19
20 if(NOT VTK_FOUND)
21   set(HAVE_VTK OFF)
22   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")
23   return()
24 endif()
25
26 # Don't support ealier VTKs
27 if(${VTK_VERSION} VERSION_LESS "5.8.0")
28   message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}")
29   return()
30 endif()
31
32 # Different Qt versions can't be linked together
33 if(HAVE_QT5 AND ${VTK_VERSION} VERSION_LESS "6.0.0")
34   if(VTK_USE_QT)
35     message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
36   endif()
37 endif()
38
39 # 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
40 if(HAVE_QT5 AND ${VTK_VERSION} VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
41   message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
42   message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
43   return()
44 endif()
45
46 # Different Qt versions can't be linked together
47 if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
48   if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
49     message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
50     return()
51   endif()
52
53   if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5")
54     message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5")
55     return()
56   endif()
57 endif()
58
59 set(HAVE_VTK ON)
60 message(STATUS "Found VTK ${VTK_VERSION} (${VTK_USE_FILE})")