1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
cmake_minimum_required(VERSION 2.8.8)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if(POLICY CMP0025)
cmake_policy(SET CMP0025 NEW) # CMake 3.0
endif()
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW) # CMake 3.0
endif()
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW) # CMake 3.1
endif()
project(QtImageViewer)
find_package(VTK COMPONENTS
vtkGUISupportQt
vtkIOImage
vtkInteractionImage
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingCore
)
include(${VTK_USE_FILE})
if("${VTK_QT_VERSION}" STREQUAL "")
message(FATAL_ERROR "VTK was not built with Qt")
endif()
set( Srcs main.cxx )
if(VTK_QT_VERSION VERSION_GREATER "4")
find_package(Qt5 COMPONENTS Core REQUIRED QUIET)
add_executable(qtimageviewer ${Srcs})
qt5_use_modules(qtimageviewer Core Gui Widgets)
target_link_libraries(qtimageviewer ${VTK_LIBRARIES})
else()
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
# Use what VTK built with
set(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
set(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
set(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
include_directories(${QT_INCLUDE_DIR})
add_executable(qtimageviewer ${Srcs})
target_link_libraries(qtimageviewer ${QT_LIBRARIES} ${VTK_LIBRARIES})
endif()
|