2014-02-02 22:56:55 +08:00
|
|
|
# VTK 6.x components
|
2015-12-28 23:27:10 +08:00
|
|
|
find_package(VTK QUIET COMPONENTS vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
|
|
|
IF(VTK_FOUND)
|
|
|
|
IF(VTK_RENDERING_BACKEND) #in vtk 7, the rendering backend is exported as a var.
|
2016-10-20 23:02:18 +08:00
|
|
|
find_package(VTK QUIET COMPONENTS vtkRendering${VTK_RENDERING_BACKEND} vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport vtkIOGeometry NO_MODULE)
|
2015-12-28 23:27:10 +08:00
|
|
|
ELSE(VTK_RENDERING_BACKEND)
|
|
|
|
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
|
|
|
|
ENDIF(VTK_RENDERING_BACKEND)
|
|
|
|
ENDIF(VTK_FOUND)
|
2014-02-02 22:56:55 +08:00
|
|
|
|
|
|
|
# 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")
|
2014-01-23 18:41:21 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2018-02-07 19:59:15 +08:00
|
|
|
# Don't support earlier VTKs
|
2018-10-21 23:02:40 +08:00
|
|
|
if(VTK_VERSION VERSION_LESS "5.8.0")
|
2014-02-02 22:56:55 +08:00
|
|
|
message(STATUS "VTK support is disabled. VTK ver. 5.8.0 is minimum required, but found VTK ver. ${VTK_VERSION}")
|
|
|
|
return()
|
|
|
|
endif()
|
2014-01-19 07:16:06 +08:00
|
|
|
|
2014-02-02 22:56:55 +08:00
|
|
|
# Different Qt versions can't be linked together
|
2018-10-21 23:02:40 +08:00
|
|
|
if(HAVE_QT5 AND VTK_VERSION VERSION_LESS "6.0.0")
|
2014-02-02 22:56:55 +08:00
|
|
|
if(VTK_USE_QT)
|
|
|
|
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
|
|
|
|
endif()
|
2014-01-19 07:16:06 +08:00
|
|
|
endif()
|
|
|
|
|
2014-02-02 22:56:55 +08:00
|
|
|
# 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
|
2018-10-21 23:02:40 +08:00
|
|
|
if(HAVE_QT5 AND VTK_VERSION VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
|
2014-02-02 22:56:55 +08:00
|
|
|
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()
|
2014-01-19 07:16:06 +08:00
|
|
|
endif()
|
|
|
|
|
2014-02-02 22:56:55 +08:00
|
|
|
# Different Qt versions can't be linked together
|
2018-10-21 23:02:40 +08:00
|
|
|
if(HAVE_QT AND VTK_VERSION VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
|
2014-02-02 22:56:55 +08:00
|
|
|
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()
|
2014-01-19 07:16:06 +08:00
|
|
|
endif()
|
2014-02-02 22:56:55 +08:00
|
|
|
|
2017-05-18 18:49:46 +08:00
|
|
|
try_compile(VTK_COMPILE_STATUS
|
|
|
|
"${OpenCV_BINARY_DIR}"
|
|
|
|
"${OpenCV_SOURCE_DIR}/cmake/checks/vtk_test.cpp"
|
|
|
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${VTK_INCLUDE_DIRS}"
|
|
|
|
LINK_LIBRARIES ${VTK_LIBRARIES}
|
|
|
|
OUTPUT_VARIABLE OUTPUT
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT ${VTK_COMPILE_STATUS})
|
|
|
|
message(STATUS "VTK support is disabled. Compilation of the sample code has failed.")
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2014-02-02 22:56:55 +08:00
|
|
|
set(HAVE_VTK ON)
|
2017-11-14 22:07:04 +08:00
|
|
|
message(STATUS "Found VTK ${VTK_VERSION} (${VTK_USE_FILE})")
|