OpenCVFindLibsGUI.cmake 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # ----------------------------------------------------------------------------
  2. # Detect 3rd-party GUI libraries
  3. # ----------------------------------------------------------------------------
  4. # --- QT4/5 ---
  5. ocv_clear_vars(HAVE_QT HAVE_QT5)
  6. macro(ocv_find_package_Qt4)
  7. find_package(Qt4 COMPONENTS QtCore QtGui QtTest ${ARGN})
  8. if(QT4_FOUND)
  9. set(QT_FOUND 1)
  10. ocv_assert(QT_VERSION_MAJOR EQUAL 4)
  11. endif()
  12. endmacro()
  13. macro(ocv_find_package_Qt OCV_QT_VER)
  14. find_package(Qt${OCV_QT_VER} COMPONENTS Core Gui Widgets Test Concurrent ${ARGN} NO_MODULE)
  15. if(Qt${OCV_QT_VER}_FOUND)
  16. set(QT_FOUND 1)
  17. set(QT_VERSION "${Qt${OCV_QT_VER}_VERSION}")
  18. set(QT_VERSION_MAJOR "${Qt${OCV_QT_VER}_VERSION_MAJOR}")
  19. set(QT_VERSION_MINOR "${Qt${OCV_QT_VER}_VERSION_MINOR}")
  20. set(QT_VERSION_PATCH "${Qt${OCV_QT_VER}_VERSION_PATCH}")
  21. set(QT_VERSION_TWEAK "${Qt${OCV_QT_VER}_VERSION_TWEAK}")
  22. set(QT_VERSION_COUNT "${Qt${OCV_QT_VER}_VERSION_COUNT}")
  23. endif()
  24. endmacro()
  25. if(WITH_QT)
  26. if(NOT WITH_QT GREATER 0)
  27. # BUG: Qt5Config.cmake script can't handle components properly: find_package(QT NAMES Qt6 Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets Test Concurrent)
  28. ocv_find_package_Qt(6 QUIET)
  29. if(NOT QT_FOUND)
  30. ocv_find_package_Qt(5 QUIET)
  31. endif()
  32. if(NOT QT_FOUND)
  33. ocv_find_package_Qt4(QUIET)
  34. endif()
  35. elseif(WITH_QT EQUAL 4)
  36. ocv_find_package_Qt4(REQUIRED)
  37. else() # WITH_QT=<major version>
  38. ocv_find_package_Qt("${WITH_QT}" REQUIRED)
  39. endif()
  40. if(QT_FOUND)
  41. set(HAVE_QT ON)
  42. if(QT_VERSION_MAJOR GREATER 4)
  43. find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL QUIET)
  44. if(Qt${QT_VERSION_MAJOR}OpenGL_FOUND)
  45. set(QT_QTOPENGL_FOUND ON) # HAVE_QT_OPENGL is defined below
  46. if(QT_VERSION_MAJOR GREATER 5) # QGL -> QOpenGL
  47. find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets QUIET)
  48. if(NOT Qt${QT_VERSION_MAJOR}OpenGLWidgets_FOUND)
  49. message(STATUS "Qt OpenGLWidgets component not found: turning off Qt OpenGL functionality")
  50. set(QT_QTOPENGL_FOUND FALSE)
  51. endif()
  52. endif()
  53. endif()
  54. endif()
  55. endif()
  56. endif()
  57. # --- OpenGl ---
  58. ocv_clear_vars(HAVE_OPENGL HAVE_QT_OPENGL)
  59. if(WITH_OPENGL)
  60. if(WITH_WIN32UI OR (HAVE_QT AND QT_QTOPENGL_FOUND) OR HAVE_GTKGLEXT)
  61. find_package (OpenGL QUIET)
  62. if(OPENGL_FOUND)
  63. set(HAVE_OPENGL TRUE)
  64. if(QT_QTOPENGL_FOUND)
  65. set(HAVE_QT_OPENGL TRUE)
  66. else()
  67. ocv_include_directories(${OPENGL_INCLUDE_DIR})
  68. endif()
  69. endif()
  70. endif()
  71. endif(WITH_OPENGL)
  72. # --- Cocoa ---
  73. if(APPLE)
  74. if(NOT IOS AND CV_CLANG)
  75. set(HAVE_COCOA YES)
  76. endif()
  77. endif()