Package: gnuradio / 3.7.13.4-4

qt5-maint-0008-gr-qtgui-Allow-build-with-Qt4-or-Qt5-default.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From aa06972a708d3559eae667dd9484edadf722d73c Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul.cercueil@analog.com>
Date: Mon, 20 Jun 2016 18:37:43 +0200
Subject: [PATCH 08/22] gr-qtgui: Allow build with Qt4 or Qt5 (default)

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
---
 gr-qtgui/CMakeLists.txt                      | 27 ++++++++++++++++++++-------
 gr-qtgui/examples/c++/CMakeLists.txt         | 11 ++++++++---
 gr-qtgui/include/gnuradio/qtgui/form_menus.h |  4 ++++
 gr-qtgui/lib/CMakeLists.txt                  | 14 ++++++++++----
 4 files changed, 42 insertions(+), 14 deletions(-)

--- a/gr-qtgui/CMakeLists.txt
+++ b/gr-qtgui/CMakeLists.txt
@@ -22,14 +22,27 @@
 ########################################################################
 include(GrBoost)
 
-find_package(Qt5Widgets)
-
-find_package(Qwt)
-
 find_package(PythonLibs 2)
 
 include(GrPython)
-GR_PYTHON_CHECK_MODULE("PyQt5" PyQt5 True PYQT5_FOUND)
+
+set(DESIRED_QT_VERSION 5 CACHE STRING "The Qt version to use (4 or 5)")
+set_property(CACHE DESIRED_QT_VERSION PROPERTY STRINGS 4 5)
+
+if (DESIRED_QT_VERSION MATCHES 4)
+    find_package(Qt4 COMPONENTS QtCore QtGui)
+    set(QT_FOUND ${Qt4_FOUND})
+    include(GrSetupQt4)
+else()
+    find_package(Qt5Widgets)
+    set(QT_FOUND ${Qt5Widgets_FOUND})
+    set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
+    set(QT_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS})
+endif()
+
+GR_PYTHON_CHECK_MODULE("PyQt${DESIRED_QT_VERSION}" PyQt${DESIRED_QT_VERSION} True PYQT${DESIRED_QT_VERSION}_FOUND)
+
+find_package(Qwt)
 
 ########################################################################
 # Register component
@@ -37,13 +50,13 @@
 include(GrComponent)
 if(NOT CMAKE_CROSSCOMPILING)
     set(qt_gui_python_deps
-        PYQT5_FOUND
+        PYQT${DESIRED_QT_VERSION}_FOUND
     )
 endif(NOT CMAKE_CROSSCOMPILING)
 
 GR_REGISTER_COMPONENT("gr-qtgui" ENABLE_GR_QTGUI
     Boost_FOUND
-    Qt5Widgets_FOUND
+    QT_FOUND
     QWT_FOUND
     ENABLE_VOLK
     ENABLE_GNURADIO_RUNTIME
--- a/gr-qtgui/examples/c++/CMakeLists.txt
+++ b/gr-qtgui/examples/c++/CMakeLists.txt
@@ -24,7 +24,7 @@
 	${GR_BLOCKS_INCLUDE_DIRS}
 	${GR_FFT_INCLUDE_DIRS}
 	${GNURADIO_RUNTIME_INCLUDE_DIRS}
-        ${Qt5Widgets_INCLUDE_DIRS}
+        ${QT_INCLUDE_DIRS}
         ${Boost_INCLUDE_DIRS}
 )
 
@@ -36,10 +36,15 @@
   gnuradio-fft
   gnuradio-runtime
   ${QWT_LIBRARY_DIRS}
-  ${Qt5Widgets_LIBRARIES}
+  ${QT_LIBRARIES}
 )
 
-QT5_WRAP_CPP(qtgui_moc_sources display_qt.h)
+if (${DESIRED_QT_VERSION} MATCHES 4)
+    QT4_WRAP_CPP(qtgui_moc_sources display_qt.h)
+else()
+    QT5_WRAP_CPP(qtgui_moc_sources display_qt.h)
+endif()
+
 add_executable(display_qt display_qt.cc ${qtgui_moc_sources})
 target_link_libraries(display_qt ${QTGUI_LIBRARIES})
 
--- a/gr-qtgui/include/gnuradio/qtgui/form_menus.h
+++ b/gr-qtgui/include/gnuradio/qtgui/form_menus.h
@@ -28,7 +28,11 @@
 #include <QtGui/QtGui>
 #include <QtGui/QIntValidator>
 #include <QtGui/QDoubleValidator>
+
+#if QT_VERSION >= 0x050000
 #include <QtWidgets/QtWidgets>
+#endif
+
 #include <qwt_symbol.h>
 #include <gnuradio/filter/firdes.h>
 #include <gnuradio/qtgui/qtgui_types.h>
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -45,8 +45,14 @@
     ${qtgui_mod_includedir}/VectorDisplayPlot.h
     edit_box_msg_impl.h
 )
-QT5_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
-QT5_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+
+if (${DESIRED_QT_VERSION} MATCHES 4)
+    QT4_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
+    QT4_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+else()
+    QT5_WRAP_CPP(qtgui_moc_sources ${qtgui_moc_hdrs})
+    QT5_WRAP_UI(qtgui_ui_hdrs spectrumdisplayform.ui)
+endif()
 
 #FIXME the sources expect <foo>.ui.h, but the macros generate ui_foo.h
 #avoid changing the sources by generating the header with the include
@@ -127,7 +133,7 @@
     ${GNURADIO_RUNTIME_INCLUDE_DIRS}
     ${VOLK_INCLUDE_DIRS}
     ${QWT_INCLUDE_DIRS}
-    ${Qt5Widgets_INCLUDE_DIRS}
+    ${QT_INCLUDE_DIRS}
     ${FFTW3F_INCLUDE_DIRS}
     ${Boost_INCLUDE_DIRS}
     ${PYTHON_INCLUDE_DIRS}
@@ -154,7 +160,7 @@
     gnuradio-filter
     ${VOLK_LIBRARIES}
     ${QWT_LIBRARIES}
-    ${Qt5Widgets_LIBRARIES}
+    ${QT_LIBRARIES}
     ${FFTW3F_LIBRARIES}
 )
 if (WIN32)