1 # - Find PyQt4 installation
2 # Sets the following variables:
3 # PYQT_PYUIC_EXECUTABLE - path to the pyuic executable
4 # PYQT_PYRCC_EXECUTABLE - path to the pyrcc executable
5 # PYQT_PYUIC_PATH - command to launch pyuic with the correct PYTHONPATH
6 # PYQT_PYRCC_PATH - command to launch pyrcc with the correct PYTHONPATH
7 # PYQT_PYTHONPATH - path to the PyQt Python modules
8 # PYQT_SIPS_DIR - path to main include directory (which contains several sub folders)
9 # PYQT_INCLUDE_DIRS - list of paths to include when compiling (all rooted on PYQT_SIP_DIRS)
10 # PYQT_SIPFLAGS - compilation flags extracted from PyQt
16 # pyqtconfig.Configuration().pyqt_sip_flags
17 # is called to get the compilation flags.
18 # Headers are located by looking for the header file
21 #########################################################################
22 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
24 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
25 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
27 # This library is free software; you can redistribute it and/or
28 # modify it under the terms of the GNU Lesser General Public
29 # License as published by the Free Software Foundation; either
30 # version 2.1 of the License.
32 # This library is distributed in the hope that it will be useful,
33 # but WITHOUT ANY WARRANTY; without even the implied warranty of
34 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 # Lesser General Public License for more details.
37 # You should have received a copy of the GNU Lesser General Public
38 # License along with this library; if not, write to the Free Software
39 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
44 IF(NOT PyQt4_FIND_QUIETLY)
45 MESSAGE(STATUS "Looking for PyQt4 ...")
48 IF(NOT SIP_FOUND AND NOT PyQt4_FIND_QUIETLY)
49 MESSAGE(WARNING "PyQt4 needs SIP to be detected correctly!")
52 FIND_PROGRAM(PYQT_PYUIC_EXECUTABLE NAMES pyuic4 pyuic4.bat)
53 FIND_PROGRAM(PYQT_PYRCC_EXECUTABLE NAMES pyrcc4 pyrcc4.bat)
55 # Get root dir locally, going up two levels from the exec:
56 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYQT_PYUIC_EXECUTABLE}" PATH)
57 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
60 # Typical locations of qobject.sip are:
61 # - /usr/share/sip/PyQt4/QtCore, for a system install
62 # - or <xyz>/sip/QtCore, for a custom install
63 # - or <xyz>/share/sip/QtCore, for a custom install
64 FIND_FILE(PYQT_SIP_MAIN_FILE qobject.sip PATH_SUFFIXES share/sip/QtCore sip/QtCore share/sip/PyQt4/QtCore)
66 IF(PYQT_SIP_MAIN_FILE)
67 GET_FILENAME_COMPONENT(PYQT_SIPS_DIR "${PYQT_SIP_MAIN_FILE}" PATH)
68 GET_FILENAME_COMPONENT(PYQT_SIPS_DIR "${PYQT_SIPS_DIR}" PATH)
70 MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE)
72 # Get PyQt compilation flags:
73 SET(PYQT_PYTHONPATH ${_tmp_ROOT_DIR}/PyQt4)
76 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;
77 sys.path[:0] = '${PYQT_PYTHONPATH}'.split(';');
78 sys.path[:0] = '${SIP_PYTHONPATH}'.split(';');
79 from PyQt4 import pyqtconfig;
80 sys.stdout.write(pyqtconfig.Configuration().pyqt_sip_flags)"
81 OUTPUT_VARIABLE PYQT_SIPFLAGS)
82 SEPARATE_ARGUMENTS(PYQT_SIPFLAGS)
86 "${PYQT_SIPS_DIR}/QtCore"
87 "${PYQT_SIPS_DIR}/QtGui"
88 "${PYQT_SIPS_DIR}/QtXml"
89 "${PYQT_SIPS_DIR}/QtOpenGL"
90 "${PYQT_SIPS_DIR}/QtAssistant"
91 "${PYQT_SIPS_DIR}/QtDesigner"
92 "${PYQT_SIPS_DIR}/QtNetwork"
93 "${PYQT_SIPS_DIR}/QtSql"
94 "${PYQT_SIPS_DIR}/QtSvg"
95 "${PYQT_SIPS_DIR}/QtTest"
98 SET(PYQT_CXX_EXT ".cc")
99 SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} -s ${PYQT_CXX_EXT} -c .)
100 FOREACH(_dir ${PYQT_INCLUDE_DIRS})
101 LIST(APPEND PYQT_SIPFLAGS -I ${_dir})
104 INCLUDE(FindPackageHandleStandardArgs)
105 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_EXECUTABLE PYQT_PYRCC_EXECUTABLE PYQT_SIPS_DIR PYQT_SIPFLAGS )
107 # Wrap the final executables so that they always use the proper environment (PYTHONPATH):
108 # The results are put to variables:
109 # PYQT_PYUIC_PATH - command to launch pyuic with the correct PYTHONPATH
110 # PYQT_PYRCC_PATH - command to launch pyrcc with the correct PYTHONPATH
111 # TODO: should be done like Sphinx in KERNEL (i.e. generating a shell script)?
113 IF(WIN32 AND NOT CYGWIN)
114 MESSAGE(WARNING "PyQt4 command was not tested under Win32")
115 SET(PYQT_PYUIC_PATH set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH};%PYTHONPATH% && ${PYQT_PYUIC_EXECUTABLE})
116 SET(PYQT_PYRCC_PATH set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH};%PYTHONPATH% && ${PYQT_PYRCC_EXECUTABLE})
118 STRING(REPLACE ";" ":" PYQT_PYTHONPATH "${PYQT_PYTHONPATH}")
119 SET(PYQT_PYUIC_PATH /usr/bin/env PYTHONPATH="${PYQT_PYTHONPATH}:${SIP_PYTHONPATH}:$$PYTHONPATH" ${PYQT_PYUIC_EXECUTABLE})
120 SET(PYQT_PYRCC_PATH /usr/bin/env PYTHONPATH="${PYQT_PYTHONPATH}:${SIP_PYTHONPATH}:$$PYTHONPATH" ${PYQT_PYRCC_EXECUTABLE})