summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cercueil <paul.cercueil@analog.com>2016-06-20 18:37:43 +0200
committerPaul Cercueil <paul.cercueil@analog.com>2016-06-21 17:56:13 +0200
commit22778fbd1b1a89188793b7f4c07dbe2d97a6ec67 (patch)
treebe3884000e19603af71a25156576d46de1512e2c
parent70780d6098a076c5a08bb7fce4327efa58f0daf6 (diff)
gr-qtgui: Allow build with Qt4 or Qt5 (default)
Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
-rw-r--r--gr-qtgui/CMakeLists.txt27
-rw-r--r--gr-qtgui/examples/c++/CMakeLists.txt11
-rw-r--r--gr-qtgui/include/gnuradio/qtgui/form_menus.h4
-rw-r--r--gr-qtgui/lib/CMakeLists.txt14
4 files changed, 42 insertions, 14 deletions
diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
index e3dcf7b86b..c06e516917 100644
--- 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 @@ GR_PYTHON_CHECK_MODULE("PyQt5" PyQt5 True PYQT5_FOUND)
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
diff --git a/gr-qtgui/examples/c++/CMakeLists.txt b/gr-qtgui/examples/c++/CMakeLists.txt
index 796c292b81..89b4baef71 100644
--- a/gr-qtgui/examples/c++/CMakeLists.txt
+++ b/gr-qtgui/examples/c++/CMakeLists.txt
@@ -24,7 +24,7 @@ include_directories(
${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 @@ list(APPEND QTGUI_LIBRARIES
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})
diff --git a/gr-qtgui/include/gnuradio/qtgui/form_menus.h b/gr-qtgui/include/gnuradio/qtgui/form_menus.h
index f2a0cb052f..1fa7413117 100644
--- 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>
diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt
index 4827ec4f3f..a5e63b232e 100644
--- a/gr-qtgui/lib/CMakeLists.txt
+++ b/gr-qtgui/lib/CMakeLists.txt
@@ -45,8 +45,14 @@ set(qtgui_moc_hdrs
${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 @@ include_directories(
${GNURADIO_RUNTIME_INCLUDE_DIRS}
${VOLK_INCLUDE_DIRS}
${QWT_INCLUDE_DIRS}
- ${Qt5Widgets_INCLUDE_DIRS}
+ ${QT_INCLUDE_DIRS}
${FFTW3F_INCLUDE_DIRS}
${LOG4CPP_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
@@ -156,7 +162,7 @@ list(APPEND qtgui_libs
gnuradio-filter
${VOLK_LIBRARIES}
${QWT_LIBRARIES}
- ${Qt5Widgets_LIBRARIES}
+ ${QT_LIBRARIES}
${FFTW3F_LIBRARIES}
${LOG4CPP_LIBRARIES}
)