X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=adm_local%2Fcmake_files%2FFindPyQt4.cmake;h=0d204938b71495f2b0a46ff74eee1f255488a4b3;hb=3a0ba13afff7a465ade65e11e7b84f22a658bea4;hp=5de9414215aee1f34d02a7312738ee14ba8c239a;hpb=6f75b0c075ffb1dc9b36df5d9b000b3b9f18ac36;p=modules%2Fgui.git diff --git a/adm_local/cmake_files/FindPyQt4.cmake b/adm_local/cmake_files/FindPyQt4.cmake index 5de941421..0d204938b 100644 --- a/adm_local/cmake_files/FindPyQt4.cmake +++ b/adm_local/cmake_files/FindPyQt4.cmake @@ -1,31 +1,9 @@ -# - Find PyQt4 installation -# Sets the following variables: -# PYQT_PYUIC_EXECUTABLE - command to launch pyuic with the correct PYTHONPATH -# PYQT_PYUIC_PATH - path to the pyuic executable -# PYQT_PYTHONPATH - path to the PyQt Python modules -# PYQT_SIPS_DIR - path to main include directory (which contains several sub folders) -# PYQT_INCLUDE_DIRS - list of paths to include when compiling (all rooted on PYQT_SIP_DIRS) -# PYQT_SIPFLAGS - compilation flags extracted from PyQt -# -# The executables -# pyuic4 (pyuic4.bat) -# are searched. -# The Python command -# pyqtconfig.Configuration().pyqt_sip_flags -# is called to get the compilation flags. -# Headers are located by looking for the header file -# qobject.sip - -######################################################################### -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -39,16 +17,42 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +# - Find PyQt4 installation +# Sets the following variables: +# PYQT_PYUIC_EXECUTABLE - path to the pyuic executable +# PYQT_PYRCC_EXECUTABLE - path to the pyrcc executable +# PYQT_PYUIC_PATH - command to launch pyuic with the correct PYTHONPATH +# PYQT_PYRCC_PATH - command to launch pyrcc with the correct PYTHONPATH +# PYQT_PYTHONPATH - path to the PyQt Python modules +# PYQT_SIPS_DIR - path to main include directory (which contains several sub folders) +# PYQT_INCLUDE_DIRS - list of paths to include when compiling (all rooted on PYQT_SIP_DIRS) +# PYQT_SIPFLAGS - compilation flags extracted from PyQt +# +# The executables +# pyuic4 (pyuic4.bat) +# are searched. +# The Python command +# pyqtconfig.Configuration().pyqt_sip_flags +# is called to get the compilation flags. +# Headers are located by looking for the header file +# qobject.sip + IF(NOT PyQt4_FIND_QUIETLY) MESSAGE(STATUS "Looking for PyQt4 ...") ENDIF() -FIND_PROGRAM(PYQT_PYUIC_PATH NAMES pyuic4 pyuic4.bat) +IF(NOT SIP_FOUND AND NOT PyQt4_FIND_QUIETLY) + MESSAGE(WARNING "PyQt4 needs SIP to be detected correctly!") +ENDIF() + +FIND_PROGRAM(PYQT_PYUIC_EXECUTABLE NAMES pyuic4 pyuic4.bat) +FIND_PROGRAM(PYQT_PYRCC_EXECUTABLE NAMES pyrcc4 pyrcc4.bat) # Get root dir locally, going up two levels from the exec: -GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYQT_PYUIC_PATH}" PATH) +GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYQT_PYUIC_EXECUTABLE}" PATH) GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) + # Typical locations of qobject.sip are: # - /usr/share/sip/PyQt4/QtCore, for a system install # - or /sip/QtCore, for a custom install @@ -62,11 +66,12 @@ ENDIF() MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE) # Get PyQt compilation flags: -SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") +SET(PYQT_PYTHONPATH ${_tmp_ROOT_DIR}/PyQt4) SET(PYQT_SIPFLAGS) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; -sys.path[:0] = ['${PYQT_PYTHONPATH}'] -sys.path[:0] = ['${SIP_PYTHONPATH}'] +sys.path[:0] = '${PYQT_PYTHONPATH}'.split(';'); +sys.path[:0] = '${SIP_PYTHONPATH}'.split(';'); from PyQt4 import pyqtconfig; sys.stdout.write(pyqtconfig.Configuration().pyqt_sip_flags)" OUTPUT_VARIABLE PYQT_SIPFLAGS) @@ -93,5 +98,19 @@ FOREACH(_dir ${PYQT_INCLUDE_DIRS}) ENDFOREACH() INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_PATH PYQT_SIPS_DIR PYQT_SIPFLAGS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_EXECUTABLE PYQT_PYRCC_EXECUTABLE PYQT_SIPS_DIR PYQT_SIPFLAGS ) +# Wrap the final executables so that they always use the proper environment (PYTHONPATH): +# The results are put to variables: +# PYQT_PYUIC_PATH - command to launch pyuic with the correct PYTHONPATH +# PYQT_PYRCC_PATH - command to launch pyrcc with the correct PYTHONPATH +# TODO: should be done like Sphinx in KERNEL (i.e. generating a shell script)? + +IF(WIN32 AND NOT CYGWIN) + SET(PYQT_PYUIC_PATH set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH};%PYTHONPATH% && ${PYQT_PYUIC_EXECUTABLE}) + SET(PYQT_PYRCC_PATH set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH};%PYTHONPATH% && ${PYQT_PYRCC_EXECUTABLE}) +ELSE() + STRING(REPLACE ";" ":" PYQT_PYTHONPATH "${PYQT_PYTHONPATH}") + SET(PYQT_PYUIC_PATH /usr/bin/env PYTHONPATH="${PYQT_PYTHONPATH}:${SIP_PYTHONPATH}:$$PYTHONPATH" ${PYQT_PYUIC_EXECUTABLE}) + SET(PYQT_PYRCC_PATH /usr/bin/env PYTHONPATH="${PYQT_PYTHONPATH}:${SIP_PYTHONPATH}:$$PYTHONPATH" ${PYQT_PYRCC_EXECUTABLE}) +ENDIF()