Update CMake scripts to recognize Qt 5.0

This commit is contained in:
Andrey Kamaev 2013-04-17 22:02:01 +04:00 committed by Andrey Pavlenko
parent 9cce8ca4b6
commit f856f78ac0
4 changed files with 53 additions and 12 deletions

View File

@ -594,12 +594,15 @@ endif()
status("")
status(" GUI: ")
if(HAVE_QT)
if(HAVE_QT5)
status(" QT 5.x:" HAVE_QT THEN "YES (ver ${Qt5Core_VERSION_STRING})" ELSE NO)
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO)
elseif(HAVE_QT)
status(" QT 4.x:" HAVE_QT THEN "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})" ELSE NO)
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
else()
if(DEFINED WITH_QT)
status(" QT 4.x:" NO)
status(" QT:" NO)
endif()
if(DEFINED WITH_WIN32UI)
status(" Win32 UI:" HAVE_WIN32UI THEN YES ELSE NO)

View File

@ -13,12 +13,31 @@ if(WITH_WIN32UI)
endif(WITH_WIN32UI)
# --- QT4 ---
ocv_clear_vars(HAVE_QT)
ocv_clear_vars(HAVE_QT HAVE_QT5)
if(WITH_QT)
find_package(Qt4)
if(QT4_FOUND)
set(HAVE_QT TRUE)
add_definitions(-DHAVE_QT) # We need to define the macro this way, using cvconfig.h does not work
if(NOT CMAKE_VERSION VERSION_LESS 2.8.3 AND NOT WITH_QT EQUAL 4)
find_package(Qt5Core)
find_package(Qt5Gui)
find_package(Qt5Widgets)
find_package(Qt5Test)
find_package(Qt5Concurrent)
if(Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND AND Qt5Concurrent_FOUND)
set(HAVE_QT5 ON)
set(HAVE_QT ON)
add_definitions(-DHAVE_QT)
find_package(Qt5OpenGL)
if(Qt5OpenGL_FOUND)
set(QT_QTOPENGL_FOUND ON)
endif()
endif()
endif()
if(NOT HAVE_QT)
find_package(Qt4)
if(QT4_FOUND)
set(HAVE_QT TRUE)
add_definitions(-DHAVE_QT) # We need to define the macro this way, using cvconfig.h does not work
endif()
endif()
endif()

View File

@ -70,7 +70,26 @@ set(highgui_srcs
file(GLOB highgui_ext_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
if(HAVE_QT)
if(HAVE_QT5)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc)
list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES})
foreach(dt5_dep Core Gui Widgets Test Concurrent)
add_definitions(${Qt5${dt5_dep}_DEFINITIONS})
include_directories(${Qt5${dt5_dep}_INCLUDE_DIRS})
list(APPEND HIGHGUI_LIBRARIES ${Qt5${dt5_dep}_LIBRARIES})
endforeach()
if(HAVE_QT_OPENGL)
add_definitions(${Qt5OpenGL_DEFINITIONS})
include_directories(${Qt5OpenGL_INCLUDE_DIRS})
list(APPEND HIGHGUI_LIBRARIES ${Qt5OpenGL_LIBRARIES})
endif()
elseif(HAVE_QT)
if (HAVE_QT_OPENGL)
set(QT_USE_QTOPENGL TRUE)
endif()

View File

@ -48,13 +48,13 @@
#endif
#include <QAbstractEventDispatcher>
#include <QtGui/QApplication>
#include <QApplication>
#include <QFile>
#include <QPushButton>
#include <QtGui/QGraphicsView>
#include <QGraphicsView>
#include <QSizePolicy>
#include <QInputDialog>
#include <QtGui/QBoxLayout>
#include <QBoxLayout>
#include <QSettings>
#include <qtimer.h>
#include <QtConcurrentRun>
@ -78,7 +78,7 @@
#include <QRadioButton>
#include <QButtonGroup>
#include <QMenu>
#include <QtTest/QTest>
#include <QTest>
//start private enum
enum { CV_MODE_NORMAL = 0, CV_MODE_OPENGL = 1 };