From 0c98c440115bf307a583b3cbadee7c042e7af17d Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 29 Jan 2015 11:23:14 -0800 Subject: [PATCH] Fix PyQt4 finding during compile. --- cmake/Modules/FindPyQt.py | 24 ++++++++++++++ cmake/Modules/FindPyQt4.cmake | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 cmake/Modules/FindPyQt.py create mode 100644 cmake/Modules/FindPyQt4.cmake diff --git a/cmake/Modules/FindPyQt.py b/cmake/Modules/FindPyQt.py new file mode 100644 index 0000000..5d2f951 --- /dev/null +++ b/cmake/Modules/FindPyQt.py @@ -0,0 +1,24 @@ +# Copyright (c) 2007, Simon Edwards +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +import PyQt4.pyqtconfig + +pyqtcfg = PyQt4.pyqtconfig.Configuration() +print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version) +print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str) + +pyqt_version_tag = "" +in_t = False +for item in pyqtcfg.pyqt_sip_flags.split(' '): + if item=="-t": + in_t = True + elif in_t: + if item.startswith("Qt_4"): + pyqt_version_tag = item + else: + in_t = False +print("pyqt_version_tag:%s" % pyqt_version_tag) + +print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir) +print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags) diff --git a/cmake/Modules/FindPyQt4.cmake b/cmake/Modules/FindPyQt4.cmake new file mode 100644 index 0000000..c1f3f28 --- /dev/null +++ b/cmake/Modules/FindPyQt4.cmake @@ -0,0 +1,61 @@ +# Find PyQt4 +# ~~~~~~~~~~ +# Copyright (c) 2007-2008, Simon Edwards +# Copyright (c) 2012, Nicholas Corgan +# 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)