1# ----------------------------------------------------------------------------
2#  Detect 3rd-party GUI libraries
3# ----------------------------------------------------------------------------
4
5#--- Win32 UI ---
6ocv_clear_vars(HAVE_WIN32UI)
7if(WITH_WIN32UI)
8  try_compile(HAVE_WIN32UI
9    "${OpenCV_BINARY_DIR}"
10    "${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
11    CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
12endif()
13
14# --- QT4 ---
15ocv_clear_vars(HAVE_QT HAVE_QT5)
16if(WITH_QT)
17  if(NOT WITH_QT EQUAL 4)
18    find_package(Qt5Core)
19    find_package(Qt5Gui)
20    find_package(Qt5Widgets)
21    find_package(Qt5Test)
22    find_package(Qt5Concurrent)
23    if(Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Widgets_FOUND AND Qt5Test_FOUND AND Qt5Concurrent_FOUND)
24      set(HAVE_QT5 ON)
25      set(HAVE_QT  ON)
26      find_package(Qt5OpenGL)
27      if(Qt5OpenGL_FOUND)
28        set(QT_QTOPENGL_FOUND ON)
29      endif()
30    endif()
31  endif()
32
33  if(NOT HAVE_QT)
34    find_package(Qt4 REQUIRED QtCore QtGui QtTest)
35    if(QT4_FOUND)
36      set(HAVE_QT TRUE)
37    endif()
38  endif()
39endif()
40
41# --- GTK ---
42ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
43if(WITH_GTK AND NOT HAVE_QT)
44  if(NOT WITH_GTK_2_X)
45    CHECK_MODULE(gtk+-3.0 HAVE_GTK3)
46    if(HAVE_GTK3)
47      set(HAVE_GTK TRUE)
48    endif()
49  endif()
50  if(NOT HAVE_GTK)
51    CHECK_MODULE(gtk+-2.0 HAVE_GTK)
52    if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK))
53      message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)")
54      set(HAVE_GTK FALSE)
55    endif()
56  endif()
57  CHECK_MODULE(gthread-2.0 HAVE_GTHREAD)
58  if(HAVE_GTK AND NOT HAVE_GTHREAD)
59    message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
60  endif()
61  if(WITH_OPENGL AND NOT HAVE_GTK3)
62    CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT)
63  endif()
64endif()
65
66# --- OpenGl ---
67ocv_clear_vars(HAVE_OPENGL HAVE_QT_OPENGL)
68if(WITH_OPENGL)
69  if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTKGLEXT)
70    find_package (OpenGL QUIET)
71    if(OPENGL_FOUND)
72      set(HAVE_OPENGL TRUE)
73      list(APPEND OPENCV_LINKER_LIBS ${OPENGL_LIBRARIES})
74      if(QT_QTOPENGL_FOUND)
75        set(HAVE_QT_OPENGL TRUE)
76      else()
77        ocv_include_directories(${OPENGL_INCLUDE_DIR})
78      endif()
79    endif()
80  endif()
81endif(WITH_OPENGL)
82
83# --- Carbon & Cocoa ---
84if(APPLE)
85  if(WITH_CARBON)
86    set(HAVE_CARBON YES)
87  elseif(NOT IOS AND CMAKE_COMPILER_IS_CLANGCXX)
88    set(HAVE_COCOA YES)
89  endif()
90endif()
91