commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/09: gr-qtgui: Allow build with Qt4 or Qt


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/09: gr-qtgui: Allow build with Qt4 or Qt5 (default)
Date: Wed, 22 Jun 2016 21:19:31 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch next-qt5
in repository gnuradio.

commit 22778fbd1b1a89188793b7f4c07dbe2d97a6ec67
Author: Paul Cercueil <address@hidden>
Date:   Mon Jun 20 18:37:43 2016 +0200

    gr-qtgui: Allow build with Qt4 or Qt5 (default)
    
    Signed-off-by: Paul Cercueil <address@hidden>
---
 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(-)

diff --git a/gr-qtgui/CMakeLists.txt b/gr-qtgui/CMakeLists.txt
index e3dcf7b..c06e516 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 796c292..89b4bae 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 f2a0cb0..1fa7413 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 4827ec4..a5e63b2 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}
 )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]