OpenCVDetectVTK.cmake 2.05 KB
Newer Older
1 2 3 4
if(NOT WITH_VTK OR ANDROID OR IOS)
  return()
endif()

5 6 7 8 9 10 11 12 13 14 15
# VTK 6.x components
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)

# VTK 5.x components
if(NOT VTK_FOUND)
  find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE)
endif()

if(NOT VTK_FOUND)
  set(HAVE_VTK OFF)
  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 17 18
  return()
endif()

19 20 21 22 23
# Don't support ealier VTKs
if(${VTK_VERSION} VERSION_LESS "5.8.0")
  message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}")
  return()
endif()
24

25 26 27 28 29
# Different Qt versions can't be linked together
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_LESS "6.0.0")
  if(VTK_USE_QT)
    message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
  endif()
30 31
endif()

32 33 34 35 36
# 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
if(HAVE_QT5 AND ${VTK_VERSION} VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
  message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
  message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
  return()
37 38
endif()

39 40 41 42 43 44 45 46 47 48 49
# Different Qt versions can't be linked together
if(HAVE_QT AND ${VTK_VERSION} VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
  if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
    message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
    return()
  endif()

  if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5")
    message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5")
    return()
  endif()
50
endif()
51 52 53

set(HAVE_VTK ON)
message(STATUS "Found VTK ver. ${VTK_VERSION} (usefile: ${VTK_USE_FILE})")