Salome HOME
Split PyConsole in order to be used easily outside GUI of SALOME.
[modules/gui.git] / adm_local / cmake_files / FindPyQt4.cmake
index f48e7258b2548c174d31cc03e01b1fadfaa4f856..a282819ad9f32f2babcd1ddbed9dd5077b1f51d6 100644 (file)
@@ -1,3 +1,22 @@
+# 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, 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
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# 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
@@ -6,7 +25,6 @@
 #    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
 #  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
-#
-# 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.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
 IF(NOT PyQt4_FIND_QUIETLY)
   MESSAGE(STATUS "Looking for PyQt4 ...")
 ENDIF()
@@ -56,6 +51,7 @@ FIND_PROGRAM(PYQT_PYRCC_EXECUTABLE NAMES pyrcc4 pyrcc4.bat)
 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 <xyz>/sip/QtCore, for a custom install
@@ -69,42 +65,18 @@ ENDIF()
 MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE)
 
 # Get PyQt compilation flags:
-SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR};${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
+SET(PYQT_PYTHONPATH ${_tmp_ROOT_DIR}/PyQt4)
 SET(PYQT_SIPFLAGS)
 
-IF(WIN32 AND NOT CYGWIN)
-  SET(_cmd set PYTHONPATH=${PYQT_PYTHONPATH};${SIP_PYTHONPATH};%PYTHONPATH% && ${PYTHON_EXECUTABLE})
-ELSE()
-  SET(_cmd /usr/bin/env PYTHONPATH="${PYQT_PYTHONPATH}:${SIP_PYTHONPATH}:$$PYTHONPATH" ${PYTHON_EXECUTABLE})
-ENDIF()
-
-EXECUTE_PROCESS(COMMAND "${_cmd}" -c "import sys; 
-sys.path[:0] = ['${PYQT_PYTHONPATH}'] 
-sys.path[:0] = ['${SIP_PYTHONPATH}']
+EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; 
+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)
 SEPARATE_ARGUMENTS(PYQT_SIPFLAGS)
 
-SET(PYQT_INCLUDE_DIRS
-  "${PYQT_SIPS_DIR}"
-  "${PYQT_SIPS_DIR}/QtCore"
-  "${PYQT_SIPS_DIR}/QtGui"
-  "${PYQT_SIPS_DIR}/QtXml"
-  "${PYQT_SIPS_DIR}/QtOpenGL"
-  "${PYQT_SIPS_DIR}/QtAssistant"
-  "${PYQT_SIPS_DIR}/QtDesigner"
-  "${PYQT_SIPS_DIR}/QtNetwork"
-  "${PYQT_SIPS_DIR}/QtSql"
-  "${PYQT_SIPS_DIR}/QtSvg"
-  "${PYQT_SIPS_DIR}/QtTest"
-)
-
-SET(PYQT_CXX_EXT ".cc")
-SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} -s ${PYQT_CXX_EXT} -c .)
-FOREACH(_dir ${PYQT_INCLUDE_DIRS})
-  LIST(APPEND PYQT_SIPFLAGS -I ${_dir})
-ENDFOREACH()
+SET(PYQT_SIPFLAGS ${PYQT_SIPFLAGS} -I "${PYQT_SIPS_DIR}")
 
 INCLUDE(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_EXECUTABLE PYQT_PYRCC_EXECUTABLE PYQT_SIPS_DIR PYQT_SIPFLAGS )
@@ -114,11 +86,12 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PyQt4 REQUIRED_VARS PYQT_PYUIC_EXECUTABLE PYQT
 #   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)
-  MESSAGE(WARNING "PyQt4 command was not tested under Win32")
   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()