File tree Expand file tree Collapse file tree 4 files changed +74
-0
lines changed
Expand file tree Collapse file tree 4 files changed +74
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ if(WITH_QT)
3131 # BUG: Qt5Config.cmake script can't handle components properly: find_package(QT NAMES Qt6 Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets Test Concurrent)
3232 ocv_find_package_Qt(6 QUIET )
3333 if (NOT QT_FOUND)
34+ hunter_add_package(Qt)
35+ find_package (Qt5Core)
36+ find_package (Qt5Gui)
37+ find_package (Qt5Widgets)
38+ find_package (Qt5Test)
39+ find_package (Qt5Concurrent)
40+
3441 ocv_find_package_Qt(5 QUIET )
3542 endif ()
3643 if (NOT QT_FOUND)
Original file line number Diff line number Diff line change @@ -387,3 +387,37 @@ endif()
387387if ("@OPENEXR_FOUND@" )
388388 find_dependency(OpenEXR CONFIG)
389389endif ()
390+
391+ # AWP: Qt5 dependencies -- start
392+ if ("@Qt5Core_FOUND@" )
393+ find_dependency(Qt5Core)
394+ endif ()
395+
396+ if ("@Qt5Gui_FOUND@" )
397+ find_dependency(Qt5Gui)
398+ endif ()
399+
400+ if ("@Qt5Widgets_FOUND@" )
401+ find_dependency(Qt5Widgets)
402+ _qt_cmake_extra_helpers_add_interface(opencv_highgui Qt5::Widgets)
403+ if (NOT "@BUILD_SHARED_LIBS@" )
404+ # function from Hunter's QtCMakeExtra project
405+ _qt_cmake_extra_helpers_add_source(
406+ opencv_highgui "static_opencv_qt_resources.cpp"
407+ )
408+ endif ()
409+ endif ()
410+
411+ if ("@Qt5Test_FOUND@" )
412+ find_dependency(Qt5Test)
413+ endif ()
414+
415+ if ("@Qt5Concurrent_FOUND@" )
416+ find_dependency(Qt5Concurrent)
417+ endif ()
418+
419+ if ("@Qt5OpenGL_FOUND@" )
420+ find_dependency(Qt5OpenGL)
421+ endif ()
422+ # AWP: Qt5 dependencies -- end
423+
Original file line number Diff line number Diff line change @@ -88,6 +88,17 @@ elseif(HAVE_QT)
8888 QT6_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR} /src/window_QT.qrc)
8989 QT6_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR} /src/window_QT.h)
9090 elseif (QT_VERSION_MAJOR EQUAL 5)
91+ # Hunter patch to load qt resources when static linking
92+ # Hunter has only Qt5, so its guarded by if(HAVE_QT5)
93+ if (NOT BUILD_SHARED_LIBS )
94+ install (
95+ FILES
96+ ${CMAKE_CURRENT_LIST_DIR} /static_opencv_qt_resources.cpp
97+ DESTINATION
98+ "src/qt/plugins"
99+ )
100+ endif ()
101+
91102 QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR} /src/window_QT.qrc)
92103 QT5_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR} /src/window_QT.h)
93104 else ()
Original file line number Diff line number Diff line change 1+ /* *
2+ * Part of the Hunter patch for static linking OpenCV with Qt
3+ * Initializes the resources for the highgui window icons
4+ */
5+
6+ #include < QtCore>
7+
8+ inline void static_opencv_qt_resources () {
9+ Q_INIT_RESOURCE (window_QT);
10+ }
11+
12+ namespace {
13+
14+ struct static_opencv_qt_resources_initializer {
15+ static_opencv_qt_resources_initializer () {
16+ static_opencv_qt_resources ();
17+ }
18+ };
19+
20+ static_opencv_qt_resources_initializer global_instance;
21+ }
22+
You can’t perform that action at this time.
0 commit comments