Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
CMake:
- added possibility to explicitly disable building of bindings - added version checks for SIP (min. 4.5) and PyQt (min. 4.1) git-svn-id: http://svn.osgeo.org/qgis/trunk@6428 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Jan 13, 2007
1 parent
941136b
commit 617f524
Showing
3 changed files
with
118 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
# CMake module which checks for python and some its modules | ||
# there is a two-stage support for python: | ||
# - | ||
|
||
|
||
FIND_PACKAGE(PythonLibs) # MapServer export tool | ||
FIND_PACKAGE(PythonInterp) # test for sip and PyQt4 | ||
|
||
|
||
MACRO (TRY_RUN_PYTHON RESULT CMD) | ||
IF (PYTHONINTERP_FOUND) | ||
|
||
EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS -c "\"${CMD}\"" | ||
OUTPUT_VARIABLE out | ||
RETURN_VALUE retval) | ||
|
||
# optional last parameter to save the output | ||
SET (OUTPUT ${ARGV2}) | ||
IF (OUTPUT) | ||
SET(${OUTPUT} ${out}) | ||
ENDIF (OUTPUT) | ||
|
||
IF (retval EQUAL 0) | ||
SET (${RESULT} TRUE) | ||
ELSE (retval EQUAL 0) | ||
SET (${RESULT} FALSE) | ||
ENDIF (retval EQUAL 0) | ||
|
||
ELSE (PYTHONINTERP_FOUND) | ||
SET (${RESULT} FALSE) | ||
ENDIF (PYTHONINTERP_FOUND) | ||
ENDMACRO (TRY_RUN_PYTHON) | ||
|
||
# enable/disable python support (mapserver export tool and bindings) | ||
IF (PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH) | ||
SET (PYTHON_FOUND TRUE) | ||
MESSAGE(STATUS "Python libraries found") | ||
|
||
# TODO: should not be needed, report it to CMake devs | ||
IF (UNIX AND NOT APPLE) | ||
SET (PYTHON_LIBRARIES ${PYTHON_LIBRARIES} util) | ||
ENDIF (UNIX AND NOT APPLE) | ||
|
||
IF (WITH_BINDINGS) | ||
|
||
# check for SIP | ||
TRY_RUN_PYTHON (HAVE_SIP_MODULE "from sip import wrapinstance") | ||
FIND_PROGRAM (SIP_BINARY_PATH sip) | ||
|
||
IF (HAVE_SIP_MODULE AND SIP_BINARY_PATH) | ||
# check for SIP version | ||
# minimal version is 4.5 | ||
SET (SIP_MIN_VERSION 040500) | ||
TRY_RUN_PYTHON (RES "import sip\nprint '%x' % sip.SIP_VERSION" SIP_VERSION) | ||
IF (SIP_VERSION EQUAL "${SIP_MIN_VERSION}" OR SIP_VERSION GREATER "${SIP_MIN_VERSION}") | ||
SET (SIP_IS_GOOD TRUE) | ||
ENDIF (SIP_VERSION EQUAL "${SIP_MIN_VERSION}" OR SIP_VERSION GREATER "${SIP_MIN_VERSION}") | ||
|
||
IF (NOT SIP_IS_GOOD) | ||
MESSAGE (STATUS "SIP is required in version 4.5 or later!") | ||
ENDIF (NOT SIP_IS_GOOD) | ||
ELSE (HAVE_SIP_MODULE AND SIP_BINARY_PATH) | ||
MESSAGE (STATUS "SIP not found!") | ||
ENDIF (HAVE_SIP_MODULE AND SIP_BINARY_PATH) | ||
|
||
# check for PyQt4 | ||
TRY_RUN_PYTHON (HAVE_PYQT4 "from PyQt4 import QtCore, QtGui, QtNetwork, QtSvg, QtXml") | ||
|
||
IF (HAVE_PYQT4) | ||
# check for PyQt4 version | ||
# minimal version is 4.1 | ||
SET (PYQT_MIN_VERSION 040100) | ||
TRY_RUN_PYTHON (RES "from PyQt4 import QtCore\nprint '%x' % QtCore.PYQT_VERSION" PYQT_VERSION) | ||
IF (PYQT_VERSION EQUAL "${PYQT_MIN_VERSION}" OR PYQT_VERSION GREATER "${PYQT_MIN_VERSION}") | ||
SET (PYQT_IS_GOOD TRUE) | ||
ENDIF (PYQT_VERSION EQUAL "${PYQT_MIN_VERSION}" OR PYQT_VERSION GREATER "${PYQT_MIN_VERSION}") | ||
|
||
IF (NOT PYQT_IS_GOOD) | ||
MESSAGE (STATUS "PyQt4 is needed in version 4.1 or later!") | ||
ENDIF (NOT PYQT_IS_GOOD) | ||
ELSE (HAVE_PYQT4) | ||
MESSAGE (STATUS "PyQt4 not found!") | ||
ENDIF (HAVE_PYQT4) | ||
|
||
# if SIP and PyQt4 are found, enable bindings | ||
IF (SIP_IS_GOOD AND PYQT_IS_GOOD) | ||
SET (HAVE_PYTHON TRUE) | ||
MESSAGE(STATUS "Python bindings enabled") | ||
ELSE (SIP_IS_GOOD AND PYQT_IS_GOOD) | ||
SET (HAVE_PYTHON FALSE) | ||
MESSAGE(STATUS "Python bindings disabled due dependency problems!") | ||
ENDIF (SIP_IS_GOOD AND PYQT_IS_GOOD) | ||
|
||
ELSE (WITH_BINDINGS) | ||
MESSAGE(STATUS "Python bindings disabled") | ||
ENDIF (WITH_BINDINGS) | ||
|
||
ENDIF (PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH) |