Skip to content

Commit

Permalink
PyQt4 pyuic integration fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusmueller committed Jan 23, 2018
1 parent 4bc3c43 commit f117e0b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ else()
message(STATUS "LIBTOOLAME-DAB found: ${LIBTOOLAME-DAB_SOURCE_DIR}")
endif ()


find_package(PyQt4 REQUIRED)
########################################################################
# Find boost
########################################################################
Expand Down
61 changes: 61 additions & 0 deletions cmake/Modules/FindPyQt4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Find PyQt4
# ~~~~~~~~~~
# Copyright (c) 2007-2008, Simon Edwards <[email protected]>
# Copyright (c) 2012, Nicholas Corgan <[email protected]>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# PyQt4 website: http://www.riverbankcomputing.co.uk/pyqt/index.php
#
# Find the installed version of PyQt4. FindPyQt4 should only be called after
# Python has been found.
#
# This file defines the following variables:
#
# PYQT4_VERSION - The version of PyQt4 found expressed as a 6 digit hex number
# suitable for comparision as a string
#
# PYQT4_VERSION_STR - The version of PyQt4 as a human readable string.
#
# PYQT4_VERSION_TAG - The PyQt version tag using by PyQt's sip files.
#
# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files.
#
# PYQT4_SIP_FLAGS - The SIP flags used to build PyQt.

IF(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)
# Already in cache, be silent
SET(PYQT4_FOUND TRUE)
SET(PYUIC4_FOUND TRUE)
ELSE(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)

FIND_FILE(_find_pyqt_py FindPyQt.py PATHS ${CMAKE_MODULE_PATH})

EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt_py} OUTPUT_VARIABLE pyqt_config)
IF(pyqt_config)
STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})

SET(PYQT4_FOUND TRUE)
ENDIF(pyqt_config)

FIND_PROGRAM(PYUIC4_EXECUTABLE NAMES pyuic4)
IF(PYUIC4_EXECUTABLE)
SET(PYUIC4_FOUND TRUE)
ENDIF(PYUIC4_EXECUTABLE)

IF(PYQT4_FOUND AND PYUIC4_FOUND)
IF(NOT PYQT4_FIND_QUIETLY)
MESSAGE(STATUS "Found PyQt4 version: ${PYQT4_VERSION_STR}")
MESSAGE(STATUS "Found pyuic4: ${PYUIC4_EXECUTABLE}")
ENDIF(NOT PYQT4_FIND_QUIETLY)
ELSE(PYQT4_FOUND AND PYUIC4_FOUND)
IF(PYQT4_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Python")
ENDIF(PYQT4_FIND_REQUIRED)
ENDIF(PYQT4_FOUND AND PYUIC4_FOUND)

ENDIF(EXISTS PYQT4_VERSION AND EXISTS PYUIC4_EXECUTABLE)
12 changes: 6 additions & 6 deletions python/GUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ GR_PYTHON_INSTALL(
FILES
usrp_dab_rx.py
usrp_dab_tx.py
user_frontend.py
${GUI_PY}
DESTINATION ${GR_PYTHON_DIR}/dab
COMPONENT "dab_python"
)
set(GR_PKG_DAB_DATA_DIR ${GR_PKG_DATA_DIR})
install(FILES
install(FILES
DAB_logo.png
led_red.png
led_orange.png
led_green.png
DESTINATION ${GR_PKG_DAB_DATA_DIR}
led_green.png
DESTINATION ${GR_PKG_DAB_DATA_DIR}
)

########################################################################
# Generate the GUI python code user_frontend.py from the user interface user_frontend.ui
########################################################################
set(GUI_UI ${CMAKE_CURRENT_SOURCE_DIR}/user_frontend.ui)
set(GUI_PY ${CMAKE_CURRENT_BINARY_DIR}/user_frontend.py)
add_custom_command(OUTPUT ${GUI_UI}
COMMAND ${PYUIC4_EXECUTABLE} pyuic4 ${GUI_UI} -o ${GUI_PY}
add_custom_command(OUTPUT ${GUI_PY}
COMMAND ${PYUIC4_EXECUTABLE} ${GUI_UI} -o ${GUI_PY}
DEPENDS ${GUI_UI}
COMMENT "Generating python code from the user interface"
)

0 comments on commit f117e0b

Please sign in to comment.