1 # - Find PyQt4 installation
2 # Sets the following variables:
3 # PYQT_PYUIC_EXECUTABLE - command to launch pyuic with the correct PYTHONPATH
4 # PYQT_PYUIC_PATH - path to the pyuic executable
5 # PYQT_PYTHONPATH - path to the PyQt Python modules
6 # PYQT_SIPS_DIR - path to main include directory (which contains several sub folders)
7 # PYQT_INCLUDE_DIRS - list of paths to include when compiling (all rooted on PYQT_SIP_DIRS)
8 # PYQT_SIPFLAGS - compilation flags extracted from PyQt
14 # pyqtconfig.Configuration().pyqt_sip_flags
15 # is called to get the compilation flags.
16 # Headers are located by looking for the header file
19 #########################################################################
20 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
22 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
23 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
25 # This library is free software; you can redistribute it and/or
26 # modify it under the terms of the GNU Lesser General Public
27 # License as published by the Free Software Foundation; either
28 # version 2.1 of the License.
30 # This library is distributed in the hope that it will be useful,
31 # but WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 # Lesser General Public License for more details.
35 # You should have received a copy of the GNU Lesser General Public
36 # License along with this library; if not, write to the Free Software
37 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
42 IF(NOT PyQt4_FIND_QUIETLY)
43 MESSAGE(STATUS "Looking for PyQt4 ...")
46 FIND_PROGRAM(PYQT_PYUIC_PATH NAMES pyuic4 pyuic4.bat)
48 # Get root dir locally, going up two levels from the exec:
49 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${PYQT_PYUIC_PATH}" PATH)
50 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
52 # Typical locations of qobject.sip are:
53 # - /usr/share/sip/PyQt4/QtCore, for a system install
54 # - or <xyz>/sip/QtCore, for a custom install
55 # - or <xyz>/share/sip/QtCore, for a custom install
56 FIND_FILE(PYQT_SIP_MAIN_FILE qobject.sip PATH_SUFFIXES share/sip/QtCore sip/QtCore share/sip/PyQt4/QtCore)
58 IF(PYQT_SIP_MAIN_FILE)
59 GET_FILENAME_COMPONENT(PYQT_SIPS_DIR "${PYQT_SIP_MAIN_FILE}" PATH)
60 GET_FILENAME_COMPONENT(PYQT_SIPS_DIR "${PYQT_SIPS_DIR}" PATH)
62 MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE)
64 # Get PyQt compilation flags:
65 SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
67 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;
68 sys.path[:0] = ['${PYQT_PYTHONPATH}']
69 sys.path[:0] = ['${SIP_PYTHONPATH}']
70 from PyQt4 import pyqtconfig;
71 sys.stdout.write(pyqtconfig.Configuration().pyqt_sip_flags)"
72 OUTPUT_VARIABLE PYQT_SIPFLAGS)
73 SEPARATE_ARGUMENTS(PYQT_SIPFLAGS)
77 "${PYQT_SIPS_DIR}/QtCore"
78 "${PYQT_SIPS_DIR}/QtGui"
79 "${PYQT_SIPS_DIR}/QtXml"
80 "${PYQT_SIPS_DIR}/QtOpenGL"
81 "${PYQT_SIPS_DIR}/QtAssistant"
82 "${PYQT_SIPS_DIR}/QtDesigner"
83 "${PYQT_SIPS_DIR}/QtNetwork"
84 "${PYQT_SIPS_DIR}/QtSql"
85 "${PYQT_SIPS_DIR}/QtSvg"
86 "${PYQT_SIPS_DIR}/QtTest"
89 SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} -s .cc -c .)
90 FOREACH(_dir ${PYQT_INCLUDE_DIRS})
91 LIST(APPEND PYQT_SIPFLAGS -I ${_dir})
94 # Wrap the final executable so that it always uses the proper environment:
95 IF(WIN32 AND NOT CYGWIN)
96 MESSAGE(WARNING "PyQt4 command was not tested under Linux")
97 SET(PYQT_PYUIC_EXECUTABLE set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH} && ${PYQT_PYUIC_PATH})
99 SET(PYQT_PYUIC_EXECUTABLE /usr/bin/env PYTHONPATH=${PYQT_PYTHONPATH}:${SIP_PYTHONPATH} ${PYQT_PYUIC_PATH})
102 INCLUDE(FindPackageHandleStandardArgs)
103 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_PATH PYQT_SIPS_DIR PYQT_SIPFLAGS)