Skip to content

Commit

Permalink
Update CMake scripts to recognize Qt 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Kamaev authored and Andrey Pavlenko committed May 13, 2013
1 parent 9cce8ca commit f856f78
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 24 additions & 5 deletions cmake/OpenCVFindLibsGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
21 changes: 20 additions & 1 deletion modules/highgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions modules/highgui/src/window_QT.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 };
Expand Down

0 comments on commit f856f78

Please sign in to comment.