[QGIS Commit] r12774 - in trunk/qgis: . cmake python src
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Jan 16 06:04:42 EST 2010
Author: wonder
Date: 2010-01-16 06:04:41 -0500 (Sat, 16 Jan 2010)
New Revision: 12774
Added:
trunk/qgis/cmake/FindLibPython.py
trunk/qgis/cmake/FindPyQt.py
trunk/qgis/cmake/FindPyQt4.cmake
trunk/qgis/cmake/FindPythonLibrary.cmake
trunk/qgis/cmake/FindSIP.cmake
trunk/qgis/cmake/FindSIP.py
trunk/qgis/cmake/PyQt4Macros.cmake
trunk/qgis/cmake/PythonCompile.py
trunk/qgis/cmake/PythonMacros.cmake
trunk/qgis/cmake/SIPMacros.cmake
Removed:
trunk/qgis/cmake/Python.cmake
trunk/qgis/python/configure.py.in
trunk/qgis/python/qgisconfig.py.in
Modified:
trunk/qgis/CMakeLists.txt
trunk/qgis/python/CMakeLists.txt
trunk/qgis/src/CMakeLists.txt
Log:
Native and faster compilation of python bindings (#2370)
Modified: trunk/qgis/CMakeLists.txt
===================================================================
--- trunk/qgis/CMakeLists.txt 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/CMakeLists.txt 2010-01-16 11:04:41 UTC (rev 12774)
@@ -157,13 +157,6 @@
FIND_PACKAGE(SPATIALITE)
ENDIF (WITH_SPATIALITE AND NOT WITH_INTERNAL_SPATIALITE)
-IF (WITH_BINDINGS)
- # python support:
- # - mapserver export tool
- # - bindings
- INCLUDE (Python) # file cmake/Python.cmake
-ENDIF (WITH_BINDINGS)
-
IF (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
MESSAGE (SEND_ERROR "Some dependencies were not found!")
ENDIF (NOT PROJ_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
@@ -351,6 +344,32 @@
ENDIF (UNIX)
#############################################################
+# Python bindings
+
+IF (WITH_BINDINGS)
+
+ # python support: check for interpreter, sip, pyqt4
+ FIND_PACKAGE(PythonInterp REQUIRED)
+ FIND_PACKAGE(PythonLibrary REQUIRED)
+ FIND_PACKAGE(SIP REQUIRED)
+ FIND_PACKAGE(PyQt4 REQUIRED)
+ INCLUDE(PythonMacros)
+ INCLUDE(SIPMacros)
+ INCLUDE(PyQt4Macros)
+
+ # setup SIP variables
+ separate_arguments(PYQT4_SIP_FLAGS) # convert space separated values to a list
+ set(SIP_INCLUDES ${PYQT4_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
+ set(SIP_CONCAT_PARTS 4)
+ set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS})
+
+ IF (NOT BINDINGS_GLOBAL_INSTALL)
+ set(PYTHON_SITE_PACKAGES_DIR ${QGIS_DATA_DIR}/python)
+ ENDIF (NOT BINDINGS_GLOBAL_INSTALL)
+
+ENDIF (WITH_BINDINGS)
+
+#############################################################
# create qgsconfig.h
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake_templates/qgsconfig.h.in ${CMAKE_BINARY_DIR}/qgsconfig.h)
@@ -401,11 +420,9 @@
SUBDIRS(src doc images resources i18n)
-IF (HAVE_PYTHON AND WITH_BINDINGS)
+IF (WITH_BINDINGS)
SUBDIRS (python)
-ELSE (HAVE_PYTHON AND WITH_BINDINGS)
- MESSAGE (STATUS "Python not being built")
-ENDIF (HAVE_PYTHON AND WITH_BINDINGS)
+ENDIF (WITH_BINDINGS)
IF (ENABLE_TESTS)
#create a variable to specify where our test data is
Added: trunk/qgis/cmake/FindLibPython.py
===================================================================
--- trunk/qgis/cmake/FindLibPython.py (rev 0)
+++ trunk/qgis/cmake/FindLibPython.py 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,13 @@
+
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+import sys
+import distutils.sysconfig
+
+print("exec_prefix:%s" % sys.exec_prefix)
+print("short_version:%s" % sys.version[:3])
+print("long_version:%s" % sys.version.split()[0])
+print("py_inc_dir:%s" % distutils.sysconfig.get_python_inc())
+print("site_packages_dir:%s" % distutils.sysconfig.get_python_lib(plat_specific=1))
Added: trunk/qgis/cmake/FindPyQt.py
===================================================================
--- trunk/qgis/cmake/FindPyQt.py (rev 0)
+++ trunk/qgis/cmake/FindPyQt.py 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,24 @@
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+import PyQt4.pyqtconfig
+
+pyqtcfg = PyQt4.pyqtconfig.Configuration()
+print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
+print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)
+
+pyqt_version_tag = ""
+in_t = False
+for item in pyqtcfg.pyqt_sip_flags.split(' '):
+ if item=="-t":
+ in_t = True
+ elif in_t:
+ if item.startswith("Qt_4"):
+ pyqt_version_tag = item
+ else:
+ in_t = False
+print("pyqt_version_tag:%s" % pyqt_version_tag)
+
+print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
+print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
Added: trunk/qgis/cmake/FindPyQt4.cmake
===================================================================
--- trunk/qgis/cmake/FindPyQt4.cmake (rev 0)
+++ trunk/qgis/cmake/FindPyQt4.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,53 @@
+# Find PyQt4
+# ~~~~~~~~~~
+# Copyright (c) 2007-2008, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# PyQt4 website: http://www.riverbankcomputing.co.uk/pyqt/index.php
+#
+# Find the installed version of PyQt4. FindPyQt4 should only be called after
+# Python has been found.
+#
+# This file defines the following variables:
+#
+# PYQT4_VERSION - The version of PyQt4 found expressed as a 6 digit hex number
+# suitable for comparision as a string
+#
+# PYQT4_VERSION_STR - The version of PyQt4 as a human readable string.
+#
+# PYQT4_VERSION_TAG - The PyQt version tag using by PyQt's sip files.
+#
+# PYQT4_SIP_DIR - The directory holding the PyQt4 .sip files.
+#
+# PYQT4_SIP_FLAGS - The SIP flags used to build PyQt.
+
+IF(EXISTS PYQT4_VERSION)
+ # Already in cache, be silent
+ SET(PYQT4_FOUND TRUE)
+ELSE(EXISTS PYQT4_VERSION)
+
+ FIND_FILE(_find_pyqt_py FindPyQt.py PATHS ${CMAKE_MODULE_PATH})
+
+ EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_pyqt_py} OUTPUT_VARIABLE pyqt_config)
+ IF(pyqt_config)
+ STRING(REGEX REPLACE "^pyqt_version:([^\n]+).*$" "\\1" PYQT4_VERSION ${pyqt_config})
+ STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
+ STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
+ STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
+ STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})
+
+ SET(PYQT4_FOUND TRUE)
+ ENDIF(pyqt_config)
+
+ IF(PYQT4_FOUND)
+ IF(NOT PYQT4_FIND_QUIETLY)
+ MESSAGE(STATUS "Found PyQt4 version: ${PYQT4_VERSION_STR}")
+ ENDIF(NOT PYQT4_FIND_QUIETLY)
+ ELSE(PYQT4_FOUND)
+ IF(PYQT4_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Python")
+ ENDIF(PYQT4_FIND_REQUIRED)
+ ENDIF(PYQT4_FOUND)
+
+ENDIF(EXISTS PYQT4_VERSION)
Added: trunk/qgis/cmake/FindPythonLibrary.cmake
===================================================================
--- trunk/qgis/cmake/FindPythonLibrary.cmake (rev 0)
+++ trunk/qgis/cmake/FindPythonLibrary.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,94 @@
+# Find Python
+# ~~~~~~~~~~~
+# Find the Python interpreter and related Python directories.
+#
+# This file defines the following variables:
+#
+# PYTHON_EXECUTABLE - The path and filename of the Python interpreter.
+#
+# PYTHON_SHORT_VERSION - The version of the Python interpreter found,
+# excluding the patch version number. (e.g. 2.5 and not 2.5.1))
+#
+# PYTHON_LONG_VERSION - The version of the Python interpreter found as a human
+# readable string.
+#
+# PYTHON_SITE_PACKAGES_DIR - Location of the Python site-packages directory.
+#
+# PYTHON_INCLUDE_PATH - Directory holding the python.h include file.
+#
+# PYTHON_LIBRARY, PYTHON_LIBRARIES- Location of the Python library.
+
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+
+INCLUDE(CMakeFindFrameworks)
+
+if(EXISTS PYTHON_LIBRARY)
+ # Already in cache, be silent
+ set(PYTHONLIBRARY_FOUND TRUE)
+else(EXISTS PYTHON_LIBRARY)
+
+ FIND_PACKAGE(PythonInterp)
+
+ if(PYTHONINTERP_FOUND)
+
+ FIND_FILE(_find_lib_python_py FindLibPython.py PATHS ${CMAKE_MODULE_PATH})
+
+ EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_lib_python_py} OUTPUT_VARIABLE python_config)
+ if(python_config)
+ STRING(REGEX REPLACE ".*exec_prefix:([^\n]+).*$" "\\1" PYTHON_PREFIX ${python_config})
+ STRING(REGEX REPLACE ".*\nshort_version:([^\n]+).*$" "\\1" PYTHON_SHORT_VERSION ${python_config})
+ STRING(REGEX REPLACE ".*\nlong_version:([^\n]+).*$" "\\1" PYTHON_LONG_VERSION ${python_config})
+ STRING(REGEX REPLACE ".*\npy_inc_dir:([^\n]+).*$" "\\1" PYTHON_INCLUDE_PATH ${python_config})
+ if(NOT PYTHON_SITE_PACKAGES_DIR)
+ if(NOT PYTHON_LIBS_WITH_KDE_LIBS)
+ STRING(REGEX REPLACE ".*\nsite_packages_dir:([^\n]+).*$" "\\1" PYTHON_SITE_PACKAGES_DIR ${python_config})
+ else(NOT PYTHON_LIBS_WITH_KDE_LIBS)
+ set(PYTHON_SITE_PACKAGES_DIR ${KDE4_LIB_INSTALL_DIR}/python${PYTHON_SHORT_VERSION}/site-packages)
+ endif(NOT PYTHON_LIBS_WITH_KDE_LIBS)
+ endif(NOT PYTHON_SITE_PACKAGES_DIR)
+ STRING(REGEX REPLACE "([0-9]+).([0-9]+)" "\\1\\2" PYTHON_SHORT_VERSION_NO_DOT ${PYTHON_SHORT_VERSION})
+ set(PYTHON_LIBRARY_NAMES python${PYTHON_SHORT_VERSION} python${PYTHON_SHORT_VERSION_NO_DOT})
+ if(WIN32)
+ STRING(REPLACE "\\" "/" PYTHON_SITE_PACKAGES_DIR ${PYTHON_SITE_PACKAGES_DIR})
+ endif(WIN32)
+ FIND_LIBRARY(PYTHON_LIBRARY NAMES ${PYTHON_LIBRARY_NAMES} PATHS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/libs NO_DEFAULT_PATH)
+ set(PYTHONLIBRARY_FOUND TRUE)
+ endif(python_config)
+
+ # adapted from cmake's builtin FindPythonLibs
+ if(APPLE)
+ CMAKE_FIND_FRAMEWORKS(Python)
+ set(PYTHON_FRAMEWORK_INCLUDES)
+ if(Python_FRAMEWORKS)
+ # If a framework has been selected for the include path,
+ # make sure "-framework" is used to link it.
+ if("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
+ set(PYTHON_LIBRARY "")
+ set(PYTHON_DEBUG_LIBRARY "")
+ endif("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
+ if(NOT PYTHON_LIBRARY)
+ set (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
+ endif(NOT PYTHON_LIBRARY)
+ set(PYTHONLIBRARY_FOUND TRUE)
+ endif(Python_FRAMEWORKS)
+ endif(APPLE)
+ endif(PYTHONINTERP_FOUND)
+
+ if(PYTHONLIBRARY_FOUND)
+ set(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
+ if(NOT PYTHONLIBRARY_FIND_QUIETLY)
+ message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
+ message(STATUS "Found Python version: ${PYTHON_LONG_VERSION}")
+ message(STATUS "Found Python library: ${PYTHON_LIBRARY}")
+ endif(NOT PYTHONLIBRARY_FIND_QUIETLY)
+ else(PYTHONLIBRARY_FOUND)
+ if(PYTHONLIBRARY_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find Python")
+ endif(PYTHONLIBRARY_FIND_REQUIRED)
+ endif(PYTHONLIBRARY_FOUND)
+
+endif (EXISTS PYTHON_LIBRARY)
Added: trunk/qgis/cmake/FindSIP.cmake
===================================================================
--- trunk/qgis/cmake/FindSIP.cmake (rev 0)
+++ trunk/qgis/cmake/FindSIP.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,56 @@
+# Find SIP
+# ~~~~~~~~
+#
+# SIP website: http://www.riverbankcomputing.co.uk/sip/index.php
+#
+# Find the installed version of SIP. FindSIP should be called after Python
+# has been found.
+#
+# This file defines the following variables:
+#
+# SIP_VERSION - The version of SIP found expressed as a 6 digit hex number
+# suitable for comparision as a string.
+#
+# SIP_VERSION_STR - The version of SIP found as a human readable string.
+#
+# SIP_EXECUTABLE - Path and filename of the SIP command line executable.
+#
+# SIP_INCLUDE_DIR - Directory holding the SIP C++ header file.
+#
+# SIP_DEFAULT_SIP_DIR - Default directory where .sip files should be installed
+# into.
+
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+
+IF(SIP_VERSION)
+ # Already in cache, be silent
+ SET(SIP_FOUND TRUE)
+ELSE(SIP_VERSION)
+
+ FIND_FILE(_find_sip_py FindSIP.py PATHS ${CMAKE_MODULE_PATH})
+
+ EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_sip_py} OUTPUT_VARIABLE sip_config)
+ IF(sip_config)
+ STRING(REGEX REPLACE "^sip_version:([^\n]+).*$" "\\1" SIP_VERSION ${sip_config})
+ STRING(REGEX REPLACE ".*\nsip_version_str:([^\n]+).*$" "\\1" SIP_VERSION_STR ${sip_config})
+ STRING(REGEX REPLACE ".*\nsip_bin:([^\n]+).*$" "\\1" SIP_EXECUTABLE ${sip_config})
+ STRING(REGEX REPLACE ".*\ndefault_sip_dir:([^\n]+).*$" "\\1" SIP_DEFAULT_SIP_DIR ${sip_config})
+ STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
+ SET(SIP_FOUND TRUE)
+ ENDIF(sip_config)
+
+ IF(SIP_FOUND)
+ IF(NOT SIP_FIND_QUIETLY)
+ MESSAGE(STATUS "Found SIP version: ${SIP_VERSION_STR}")
+ ENDIF(NOT SIP_FIND_QUIETLY)
+ ELSE(SIP_FOUND)
+ IF(SIP_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find SIP")
+ ENDIF(SIP_FIND_REQUIRED)
+ ENDIF(SIP_FOUND)
+
+ENDIF(SIP_VERSION)
Added: trunk/qgis/cmake/FindSIP.py
===================================================================
--- trunk/qgis/cmake/FindSIP.py (rev 0)
+++ trunk/qgis/cmake/FindSIP.py 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,15 @@
+# FindSIP.py
+#
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+import sys
+import sipconfig
+
+sipcfg = sipconfig.Configuration()
+print("sip_version:%06.0x" % sipcfg.sip_version)
+print("sip_version_str:%s" % sipcfg.sip_version_str)
+print("sip_bin:%s" % sipcfg.sip_bin)
+print("default_sip_dir:%s" % sipcfg.default_sip_dir)
+print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
Added: trunk/qgis/cmake/PyQt4Macros.cmake
===================================================================
--- trunk/qgis/cmake/PyQt4Macros.cmake (rev 0)
+++ trunk/qgis/cmake/PyQt4Macros.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,73 @@
+
+
+IF(NOT PYUIC4_PROGRAM)
+ IF (MSVC)
+ FIND_PROGRAM(PYUIC4_PROGRAM
+ NAMES pyuic4.bat
+ PATHS $ENV{LIB_DIR}/bin
+ )
+ ELSE(MSVC)
+ FIND_PROGRAM(PYUIC4_PROGRAM pyuic4)
+ ENDIF (MSVC)
+
+ IF (NOT PYUIC4_PROGRAM)
+ MESSAGE(FATAL_ERROR "pyuic4 not found - aborting")
+ ENDIF (NOT PYUIC4_PROGRAM)
+ENDIF(NOT PYUIC4_PROGRAM)
+
+# Adapted from QT4_WRAP_UI
+MACRO(PYQT4_WRAP_UI outfiles )
+ FOREACH(it ${ARGN})
+ GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
+ GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
+ SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py)
+ ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
+ COMMAND ${PYUIC4_PROGRAM} ${infile} -o ${outfile}
+ MAIN_DEPENDENCY ${infile}
+ )
+ SET(${outfiles} ${${outfiles}} ${outfile})
+ ENDFOREACH(it)
+ENDMACRO(PYQT4_WRAP_UI)
+
+IF(NOT PYRCC4_PROGRAM)
+ IF (MSVC)
+ FIND_PROGRAM(PYRCC4_PROGRAM
+ NAMES pyrcc4.exe
+ PATHS $ENV{LIB_DIR}/bin
+ )
+ ELSE(MSVC)
+ FIND_PROGRAM(PYRCC4_PROGRAM pyrcc4)
+ ENDIF (MSVC)
+
+ IF (NOT PYRCC4_PROGRAM)
+ MESSAGE(FATAL_ERROR "pyrcc4 not found - aborting")
+ ENDIF (NOT PYRCC4_PROGRAM)
+ENDIF(NOT PYRCC4_PROGRAM)
+
+# Adapted from QT4_ADD_RESOURCES
+MACRO (PYQT4_ADD_RESOURCES outfiles )
+ FOREACH (it ${ARGN})
+ GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
+ GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
+ GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
+ SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py)
+ # parse file for dependencies
+ # all files are absolute paths or relative to the location of the qrc file
+ FILE(READ "${infile}" _RC_FILE_CONTENTS)
+ STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
+ SET(_RC_DEPENDS)
+ FOREACH(_RC_FILE ${_RC_FILES})
+ STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
+ STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
+ IF(NOT _ABS_PATH_INDICATOR)
+ SET(_RC_FILE "${rc_path}/${_RC_FILE}")
+ ENDIF(NOT _ABS_PATH_INDICATOR)
+ SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
+ ENDFOREACH(_RC_FILE)
+ ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
+ COMMAND ${PYRCC4_PROGRAM} -name ${outfile} -o ${outfile} ${infile}
+ MAIN_DEPENDENCY ${infile}
+ DEPENDS ${_RC_DEPENDS})
+ SET(${outfiles} ${${outfiles}} ${outfile})
+ ENDFOREACH (it)
+ENDMACRO (PYQT4_ADD_RESOURCES)
Deleted: trunk/qgis/cmake/Python.cmake
===================================================================
--- trunk/qgis/cmake/Python.cmake 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/cmake/Python.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -1,216 +0,0 @@
-
-# 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
-
-IF(NOT PYUIC4_PROGRAM)
- IF (MSVC)
- FIND_PROGRAM(PYUIC4_PROGRAM
- NAMES pyuic4.bat
- PATHS $ENV{LIB_DIR}/bin
- )
- ELSE(MSVC)
- FIND_PROGRAM(PYUIC4_PROGRAM pyuic4)
- ENDIF (MSVC)
-
- IF (NOT PYUIC4_PROGRAM)
- MESSAGE(FATAL_ERROR "pyuic4 not found - aborting")
- ENDIF (NOT PYUIC4_PROGRAM)
-ENDIF(NOT PYUIC4_PROGRAM)
-
-# Adapted from QT4_WRAP_UI
-MACRO(PYQT4_WRAP_UI outfiles )
- FOREACH(it ${ARGN})
- GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
- GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
- SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py)
- ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
- COMMAND ${PYUIC4_PROGRAM} ${infile} -o ${outfile}
- MAIN_DEPENDENCY ${infile}
- )
- SET(${outfiles} ${${outfiles}} ${outfile})
- ENDFOREACH(it)
-ENDMACRO(PYQT4_WRAP_UI)
-
-IF(NOT PYRCC4_PROGRAM)
- IF (MSVC)
- FIND_PROGRAM(PYRCC4_PROGRAM
- NAMES pyrcc4.exe
- PATHS $ENV{LIB_DIR}/bin
- )
- ELSE(MSVC)
- FIND_PROGRAM(PYRCC4_PROGRAM pyrcc4)
- ENDIF (MSVC)
-
- IF (NOT PYRCC4_PROGRAM)
- MESSAGE(FATAL_ERROR "pyrcc4 not found - aborting")
- ENDIF (NOT PYRCC4_PROGRAM)
-ENDIF(NOT PYRCC4_PROGRAM)
-
-# Adapted from QT4_ADD_RESOURCES
-MACRO (PYQT4_ADD_RESOURCES outfiles )
- FOREACH (it ${ARGN})
- GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
- GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE)
- GET_FILENAME_COMPONENT(rc_path ${infile} PATH)
- SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py)
- # parse file for dependencies
- # all files are absolute paths or relative to the location of the qrc file
- FILE(READ "${infile}" _RC_FILE_CONTENTS)
- STRING(REGEX MATCHALL "<file[^<]+" _RC_FILES "${_RC_FILE_CONTENTS}")
- SET(_RC_DEPENDS)
- FOREACH(_RC_FILE ${_RC_FILES})
- STRING(REGEX REPLACE "^<file[^>]*>" "" _RC_FILE "${_RC_FILE}")
- STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}")
- IF(NOT _ABS_PATH_INDICATOR)
- SET(_RC_FILE "${rc_path}/${_RC_FILE}")
- ENDIF(NOT _ABS_PATH_INDICATOR)
- SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}")
- ENDFOREACH(_RC_FILE)
- ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
- COMMAND ${PYRCC4_PROGRAM} -name ${outfile} -o ${outfile} ${infile}
- MAIN_DEPENDENCY ${infile}
- DEPENDS ${_RC_DEPENDS})
- SET(${outfiles} ${${outfiles}} ${outfile})
- ENDFOREACH (it)
-ENDMACRO (PYQT4_ADD_RESOURCES)
-
-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)
-
-IF(MSVC)
- FIND_PROGRAM(SIP_MAKE_PROGRAM
- NAMES nmake.exe
- PATHS "$ENV{VCINSTALLDIR}/bin" "$ENV{PROGRAMFILES}/Microsoft Visual 9.0/VC/bin"
- )
- IF(NOT SIP_MAKE_PROGRAM)
- MESSAGE(FATAL_ERROR "nmake not found")
- ENDIF(NOT SIP_MAKE_PROGRAM)
-ELSE (MSVC)
- SET(SIP_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM})
-ENDIF (MSVC)
-
-
-# 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 (3 steps)
- # 1. can import python module?
- TRY_RUN_PYTHON (HAVE_SIP_MODULE "from sip import wrapinstance")
-
- IF (APPLE)
- SET (SIP_MAC_PATH
- /System/Library/Frameworks/Python.framework/Versions/2.5/bin
- /System/Library/Frameworks/Python.framework/Versions/2.4/bin
- /System/Library/Frameworks/Python.framework/Versions/2.3/bin)
- ENDIF (APPLE)
-
- # 2. is there sip binary? (for creating wrappers)
- FIND_PROGRAM (SIP_BINARY_PATH sip PATHS ${SIP_MAC_PATH})
-
- # 3. is there sip include file? (necessary for compilation of bindings)
- FIND_PATH (SIP_INCLUDE_DIR sip.h ${PYTHON_INCLUDE_PATH})
-
- IF (HAVE_SIP_MODULE AND SIP_BINARY_PATH AND SIP_INCLUDE_DIR)
- # check for SIP version
- # minimal version is 4.7 (to support universal builds)
- SET (SIP_MIN_VERSION 040700)
- 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.7 or later!")
- ENDIF (NOT SIP_IS_GOOD)
- ELSE (HAVE_SIP_MODULE AND SIP_BINARY_PATH AND SIP_INCLUDE_DIR)
- IF (NOT HAVE_SIP_MODULE)
- MESSAGE (STATUS "SIP python module is missing!")
- ENDIF (NOT HAVE_SIP_MODULE)
- IF (NOT SIP_BINARY_PATH)
- MESSAGE (STATUS "SIP executable is missing!")
- ENDIF (NOT SIP_BINARY_PATH)
- IF (NOT SIP_INCLUDE_DIR)
- MESSAGE (STATUS "SIP header file is missing!")
- ENDIF (NOT SIP_INCLUDE_DIR)
- ENDIF (HAVE_SIP_MODULE AND SIP_BINARY_PATH AND SIP_INCLUDE_DIR)
-
- # check for PyQt4
- TRY_RUN_PYTHON (HAVE_PYQT4 "from PyQt4 import QtCore, QtGui, QtNetwork, QtSvg, QtXml")
-
- # check whether directory with PyQt4 sip files exists
- IF (HAVE_PYQT4)
- TRY_RUN_PYTHON (RES "import PyQt4.pyqtconfig\nprint PyQt4.pyqtconfig._pkg_config['pyqt_sip_dir']" PYQT_SIP_DIR)
- IF (IS_DIRECTORY ${PYQT_SIP_DIR})
- SET (HAVE_PYQT4_SIP_DIR TRUE)
- ENDIF (IS_DIRECTORY ${PYQT_SIP_DIR})
- ENDIF (HAVE_PYQT4)
-
- IF (HAVE_PYQT4 AND HAVE_PYQT4_SIP_DIR)
- # 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 AND HAVE_PYQT4_SIP_DIR)
- IF (HAVE_PYQT4)
- MESSAGE (STATUS "PyQt4 development files are missing!")
- ELSE (HAVE_PYQT4)
- MESSAGE (STATUS "PyQt4 not found!")
- ENDIF (HAVE_PYQT4)
- ENDIF (HAVE_PYQT4 AND HAVE_PYQT4_SIP_DIR)
-
- # 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)
Added: trunk/qgis/cmake/PythonCompile.py
===================================================================
--- trunk/qgis/cmake/PythonCompile.py (rev 0)
+++ trunk/qgis/cmake/PythonCompile.py 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,4 @@
+# By Simon Edwards <simon at simonzone.com>
+# This file is in the public domain.
+import py_compile
+py_compile.main()
Added: trunk/qgis/cmake/PythonMacros.cmake
===================================================================
--- trunk/qgis/cmake/PythonMacros.cmake (rev 0)
+++ trunk/qgis/cmake/PythonMacros.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,61 @@
+# Python macros
+# ~~~~~~~~~~~~~
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# This file defines the following macros:
+#
+# PYTHON_INSTALL (SOURCE_FILE DESINATION_DIR)
+# Install the SOURCE_FILE, which is a Python .py file, into the
+# destination directory during install. The file will be byte compiled
+# and both the .py file and .pyc file will be installed.
+
+GET_FILENAME_COMPONENT(PYTHON_MACROS_MODULE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+MACRO(PYTHON_INSTALL SOURCE_FILE DESINATION_DIR)
+
+ FIND_FILE(_python_compile_py PythonCompile.py PATHS ${CMAKE_MODULE_PATH})
+
+
+ # Install the source file.
+ INSTALL(FILES ${SOURCE_FILE} DESTINATION ${DESINATION_DIR})
+
+ # Byte compile and install the .pyc file.
+ GET_FILENAME_COMPONENT(_absfilename ${SOURCE_FILE} ABSOLUTE)
+ GET_FILENAME_COMPONENT(_filename ${SOURCE_FILE} NAME)
+ GET_FILENAME_COMPONENT(_filenamebase ${SOURCE_FILE} NAME_WE)
+ GET_FILENAME_COMPONENT(_basepath ${SOURCE_FILE} PATH)
+
+ if(WIN32)
+ string(REGEX REPLACE ".:/" "/" _basepath "${_basepath}")
+ endif(WIN32)
+
+ SET(_bin_py ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filename})
+ SET(_bin_pyc ${CMAKE_CURRENT_BINARY_DIR}/${_basepath}/${_filenamebase}.pyc)
+
+ FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_basepath})
+
+ SET(_message "-DMESSAGE=Byte-compiling ${_bin_py}")
+
+ GET_FILENAME_COMPONENT(_abs_bin_py ${_bin_py} ABSOLUTE)
+ IF(_abs_bin_py STREQUAL ${_absfilename}) # Don't copy the file onto itself.
+ ADD_CUSTOM_COMMAND(
+ TARGET compile_python_files
+ COMMAND ${CMAKE_COMMAND} -E echo ${message}
+ COMMAND ${PYTHON_EXECUTABLE} ${_python_compile_py} ${_bin_py}
+ DEPENDS ${_absfilename}
+ )
+ ELSE(_abs_bin_py STREQUAL ${_absfilename})
+ ADD_CUSTOM_COMMAND(
+ TARGET compile_python_files
+ COMMAND ${CMAKE_COMMAND} -E echo ${message}
+ COMMAND ${CMAKE_COMMAND} -E copy ${_absfilename} ${_bin_py}
+ COMMAND ${PYTHON_EXECUTABLE} ${_python_compile_py} ${_bin_py}
+ DEPENDS ${_absfilename}
+ )
+ ENDIF(_abs_bin_py STREQUAL ${_absfilename})
+
+ INSTALL(FILES ${_bin_pyc} DESTINATION ${DESINATION_DIR})
+ENDMACRO(PYTHON_INSTALL)
Added: trunk/qgis/cmake/SIPMacros.cmake
===================================================================
--- trunk/qgis/cmake/SIPMacros.cmake (rev 0)
+++ trunk/qgis/cmake/SIPMacros.cmake 2010-01-16 11:04:41 UTC (rev 12774)
@@ -0,0 +1,121 @@
+# Macros for SIP
+# ~~~~~~~~~~~~~~
+# Copyright (c) 2007, Simon Edwards <simon at simonzone.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# SIP website: http://www.riverbankcomputing.co.uk/sip/index.php
+#
+# This file defines the following macros:
+#
+# ADD_SIP_PYTHON_MODULE (MODULE_NAME MODULE_SIP [library1, libaray2, ...])
+# Specifies a SIP file to be built into a Python module and installed.
+# MODULE_NAME is the name of Python module including any path name. (e.g.
+# os.sys, Foo.bar etc). MODULE_SIP the path and filename of the .sip file
+# to process and compile. libraryN are libraries that the Python module,
+# which is typically a shared library, should be linked to. The built
+# module will also be install into Python's site-packages directory.
+#
+# The behaviour of the ADD_SIP_PYTHON_MODULE macro can be controlled by a
+# number of variables:
+#
+# SIP_INCLUDES - List of directories which SIP will scan through when looking
+# for included .sip files. (Corresponds to the -I option for SIP.)
+#
+# SIP_TAGS - List of tags to define when running SIP. (Corresponds to the -t
+# option for SIP.)
+#
+# SIP_CONCAT_PARTS - An integer which defines the number of parts the C++ code
+# of each module should be split into. Defaults to 8. (Corresponds to the
+# -j option for SIP.)
+#
+# SIP_DISABLE_FEATURES - List of feature names which should be disabled
+# running SIP. (Corresponds to the -x option for SIP.)
+#
+# SIP_EXTRA_OPTIONS - Extra command line options which should be passed on to
+# SIP.
+
+SET(SIP_INCLUDES)
+SET(SIP_TAGS)
+SET(SIP_CONCAT_PARTS 8)
+SET(SIP_DISABLE_FEATURES)
+SET(SIP_EXTRA_OPTIONS)
+
+MACRO(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP)
+
+ SET(EXTRA_LINK_LIBRARIES ${ARGN})
+
+ STRING(REPLACE "." "/" _x ${MODULE_NAME})
+ GET_FILENAME_COMPONENT(_parent_module_path ${_x} PATH)
+ GET_FILENAME_COMPONENT(_child_module_name ${_x} NAME)
+
+ GET_FILENAME_COMPONENT(_module_path ${MODULE_SIP} PATH)
+ GET_FILENAME_COMPONENT(_abs_module_sip ${MODULE_SIP} ABSOLUTE)
+
+ # We give this target a long logical target name.
+ # (This is to avoid having the library name clash with any already
+ # install library names. If that happens then cmake dependancy
+ # tracking get confused.)
+ STRING(REPLACE "." "_" _logical_name ${MODULE_NAME})
+ SET(_logical_name "python_module_${_logical_name}")
+
+ FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}) # Output goes in this dir.
+
+ SET(_sip_includes)
+ FOREACH (_inc ${SIP_INCLUDES})
+ GET_FILENAME_COMPONENT(_abs_inc ${_inc} ABSOLUTE)
+ LIST(APPEND _sip_includes -I ${_abs_inc})
+ ENDFOREACH (_inc )
+
+ SET(_sip_tags)
+ FOREACH (_tag ${SIP_TAGS})
+ LIST(APPEND _sip_tags -t ${_tag})
+ ENDFOREACH (_tag)
+
+ SET(_sip_x)
+ FOREACH (_x ${SIP_DISABLE_FEATURES})
+ LIST(APPEND _sip_x -x ${_x})
+ ENDFOREACH (_x ${SIP_DISABLE_FEATURES})
+
+ SET(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
+ SET(_sip_output_files)
+ FOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
+ IF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
+ SET(_sip_output_files ${_sip_output_files} ${CMAKE_CURRENT_BINARY_DIR}/${_module_path}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
+ ENDIF( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
+ ENDFOREACH(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
+
+ IF(NOT WIN32)
+ SET(TOUCH_COMMAND touch)
+ ELSE(NOT WIN32)
+ SET(TOUCH_COMMAND echo)
+ # instead of a touch command, give out the name and append to the files
+ # this is basically what the touch command does.
+ FOREACH(filename ${_sip_output_files})
+ FILE(APPEND ${filename} "")
+ ENDFOREACH(filename ${_sip_output_files})
+ ENDIF(NOT WIN32)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${_sip_output_files}
+ COMMAND ${CMAKE_COMMAND} -E echo ${message}
+ COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
+ COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} ${_sip_includes} ${_abs_module_sip}
+ DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
+ )
+ # not sure if type MODULE could be uses anywhere, limit to cygwin for now
+ IF (CYGWIN)
+ ADD_LIBRARY(${_logical_name} MODULE ${_sip_output_files} )
+ ELSE (CYGWIN)
+ ADD_LIBRARY(${_logical_name} SHARED ${_sip_output_files} )
+ ENDIF (CYGWIN)
+ TARGET_LINK_LIBRARIES(${_logical_name} ${PYTHON_LIBRARY})
+ TARGET_LINK_LIBRARIES(${_logical_name} ${EXTRA_LINK_LIBRARIES})
+ SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES PREFIX "" OUTPUT_NAME ${_child_module_name})
+
+ IF (WIN32)
+ SET_TARGET_PROPERTIES(${_logical_name} PROPERTIES SUFFIX ".pyd")
+ ENDIF (WIN32)
+
+ INSTALL(TARGETS ${_logical_name} DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/${_parent_module_path}")
+
+ENDMACRO(ADD_SIP_PYTHON_MODULE)
Modified: trunk/qgis/python/CMakeLists.txt
===================================================================
--- trunk/qgis/python/CMakeLists.txt 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/python/CMakeLists.txt 2010-01-16 11:04:41 UTC (rev 12774)
@@ -1,105 +1,71 @@
+
SUBDIRS(plugins)
-IF (WIN32)
- SET(BINDINGS_CORE_LIB ${CMAKE_CURRENT_BINARY_DIR}/core/core.pyd)
- SET(BINDINGS_GUI_LIB ${CMAKE_CURRENT_BINARY_DIR}/gui/gui.pyd)
- SET(BINDINGS_ANALYSIS_LIB ${CMAKE_CURRENT_BINARY_DIR}/analysis/analysis.pyd)
- IF (NOT MSVC)
- SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/libqgis_core.dll)
- SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/libqgis_gui.dll)
- SET(QGIS_ANALYSIS_LIB ${CMAKE_BINARY_DIR}/src/analysis/libqgis_analysis.dll)
- ELSE (NOT MSVC)
- SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/${CMAKE_CFG_INTDIR}/qgis_core.lib)
- SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/${CMAKE_CFG_INTDIR}/qgis_gui.lib)
- SET(QGIS_ANALYSIS_LIB ${CMAKE_BINARY_DIR}/src/analysis/${CMAKE_CFG_INTDIR}/qgis_analysis.lib)
- ENDIF (NOT MSVC)
-ELSE (WIN32)
- SET(BINDINGS_CORE_LIB ${CMAKE_CURRENT_BINARY_DIR}/core/core.so)
- SET(BINDINGS_GUI_LIB ${CMAKE_CURRENT_BINARY_DIR}/gui/gui.so)
- SET(BINDINGS_ANALYSIS_LIB ${CMAKE_CURRENT_BINARY_DIR}/analysis/analysis.so)
- IF (APPLE)
- SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/libqgis_core.dylib)
- SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/libqgis_gui.dylib)
- SET(QGIS_ANALYSIS_LIB ${CMAKE_BINARY_DIR}/src/analysis/libqgis_analysis.dylib)
- ELSE (APPLE)
- SET(QGIS_CORE_LIB ${CMAKE_BINARY_DIR}/src/core/libqgis_core.so)
- SET(QGIS_GUI_LIB ${CMAKE_BINARY_DIR}/src/gui/libqgis_gui.so)
- SET(QGIS_ANALYSIS_LIB ${CMAKE_BINARY_DIR}/src/analysis/libqgis_analysis.so)
- ENDIF (APPLE)
-ENDIF (WIN32)
-SET (BINDINGS_LIBS ${BINDINGS_CORE_LIB} ${BINDINGS_GUI_LIB} ${BINDINGS_ANALYSIS_LIB})
-SET (BINDINGS_CORE_MAKEFILE ${CMAKE_CURRENT_BINARY_DIR}/core/Makefile)
-SET (BINDINGS_GUI_MAKEFILE ${CMAKE_CURRENT_BINARY_DIR}/gui/Makefile)
-SET (BINDINGS_ANALYSIS_MAKEFILE ${CMAKE_CURRENT_BINARY_DIR}/analysis/Makefile)
-# 'python' target will force to build bindings libs for core and gui
-ADD_CUSTOM_TARGET (python ALL DEPENDS ${BINDINGS_CORE_LIB} ${BINDINGS_GUI_LIB} ${BINDINGS_ANALYSIS_LIB})
+INCLUDE_DIRECTORIES(
+ ${PYTHON_INCLUDE_PATH}
+ ${SIP_INCLUDE_DIR}
+ ${QT_QTCORE_INCLUDE_DIR}
+ ${QT_QTGUI_INCLUDE_DIR}
+ ${QT_QTNETWORK_INCLUDE_DIR}
+ ${QT_QTSVG_INCLUDE_DIR}
+ ${QT_QTXML_INCLUDE_DIR}
+ ${GDAL_INCLUDE_DIR}
+ ${GEOS_INCLUDE_DIR}
-# don't run python before the libs are built
-ADD_DEPENDENCIES (python qgis_core qgis_gui qgis_analysis)
+ ../src/core
+ ../src/core/composer
+ ../src/core/raster
+ ../src/core/renderer
+ ../src/core/spatialindex
+ ../src/core/symbology
+ ../src/core/symbology-ng
+ ${CMAKE_BINARY_DIR} # qgsconfig.h, qgssvnversion.h
+)
-FILE(GLOB CORE_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/core/*.sip")
-FILE(GLOB GUI_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/gui/*.sip")
-FILE(GLOB ANALYSIS_SIP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/analysis/*.sip")
-# Step 1: during configuration
-# create file configure.py from configure.py.in
-CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/configure.py.in
- ${CMAKE_CURRENT_BINARY_DIR}/configure.py)
-
-IF (MSVC)
- SET(EXPORT "__declspec(dllimport)")
-ELSE (MSVC)
- SET(EXPORT "")
-ENDIF (MSVC)
+# In Windef.h there are min() and max() macros that interfere with the usage
+# of std::numeric_limits<T>::min() and :max() in qgsrasterbands.h.
+IF(MSVC)
+ ADD_DEFINITIONS(-DNOMINMAX)
+ENDIF(MSVC)
-# Step 2: during make
-# run python configure.py
-# it will run SIP utility to generate sources and will prepare makefiles
-# should be run everytime core or gui library has been changed
-ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_CORE_MAKEFILE} ${BINDINGS_GUI_MAKEFILE} ${BINDINGS_ANALYSIS_MAKEFILE} PRE_BUILD
- COMMAND ${PYTHON_EXECUTABLE}
- ARGS ${CMAKE_CURRENT_BINARY_DIR}/configure.py ${CMAKE_CFG_INTDIR} ${EXPORT}
- DEPENDS ${QGIS_CORE_LIB} ${QGIS_GUI_LIB} ${QGIS_ANALYSIS_LIB}
- ${CMAKE_CURRENT_BINARY_DIR}/configure.py
- ${CORE_SIP_FILES} ${GUI_SIP_FILES} ${ANALYSIS_SIP_FILES})
-# Step 3: run make in core and gui subdirs
-ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_CORE_LIB} PRE_LINK
- COMMAND ${SIP_MAKE_PROGRAM}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/core
- DEPENDS ${BINDINGS_CORE_MAKEFILE})
-ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_GUI_LIB} PRE_LINK
- COMMAND ${SIP_MAKE_PROGRAM}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gui
- DEPENDS ${BINDINGS_GUI_MAKEFILE})
-ADD_CUSTOM_COMMAND(OUTPUT ${BINDINGS_ANALYSIS_LIB} PRE_LINK
- COMMAND ${SIP_MAKE_PROGRAM}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/analysis
- DEPENDS ${BINDINGS_ANALYSIS_MAKEFILE})
+# core module
+FILE(GLOB sip_files_core core/*.sip)
+set(SIP_EXTRA_FILES_DEPEND ${sip_files_core})
+ADD_SIP_PYTHON_MODULE(qgis.core core/core.sip qgis_core)
-IF (BINDINGS_GLOBAL_INSTALL)
+# additional gui includes
+INCLUDE_DIRECTORIES(
+ ../src/gui
+ ../src/gui/symbology-ng
+ ../src/plugins
+ ${CMAKE_BINARY_DIR}/src/gui
+ ${CMAKE_BINARY_DIR}/src/ui
+)
-# python's site-packages dir: bindings will be installed here
-IF (UNIX)
- SET (CMD "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")
-ELSE (UNIX)
- SET (CMD "
-import sys
-print sys.exec_prefix + '/lib/site-packages'
-")
-ENDIF (UNIX)
+# gui module
+FILE(GLOB sip_files_gui gui/*.sip)
+set(SIP_EXTRA_FILES_DEPEND ${sip_files_gui})
+ADD_SIP_PYTHON_MODULE(qgis.gui gui/gui.sip qgis_core qgis_gui)
-EXEC_PROGRAM(${PYTHON_EXECUTABLE} ARGS -c "\"${CMD}\"" OUTPUT_VARIABLE SITE_PKG_PATH)
+# additional analysis includes
+INCLUDE_DIRECTORIES(
+ ../src/analysis/vector
+ ${CMAKE_BINARY_DIR}/src/analysis/vector
+)
-ELSE (BINDINGS_GLOBAL_INSTALL)
+# analysis module
+FILE(GLOB sip_files_analysis analysis/*.sip)
+set(SIP_EXTRA_FILES_DEPEND ${sip_files_analysis})
+ADD_SIP_PYTHON_MODULE(qgis.analysis analysis/analysis.sip qgis_core qgis_analysis)
- SET (SITE_PKG_PATH ${QGIS_DATA_DIR}/python)
-
-ENDIF (BINDINGS_GLOBAL_INSTALL)
+SET (QGIS_PYTHON_DIR ${PYTHON_SITE_PACKAGES_DIR}/qgis)
+ADD_CUSTOM_TARGET(compile_python_files ALL)
-# Step 4: install built libs to python's site packages
-INSTALL(FILES __init__.py utils.py console.py ${CMAKE_CURRENT_BINARY_DIR}/qgisconfig.py ${BINDINGS_LIBS} DESTINATION ${SITE_PKG_PATH}/qgis)
-
+PYTHON_INSTALL(__init__.py ${QGIS_PYTHON_DIR})
+PYTHON_INSTALL(utils.py ${QGIS_PYTHON_DIR})
+PYTHON_INSTALL(console.py ${QGIS_PYTHON_DIR})
Deleted: trunk/qgis/python/configure.py.in
===================================================================
--- trunk/qgis/python/configure.py.in 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/python/configure.py.in 2010-01-16 11:04:41 UTC (rev 12774)
@@ -1,213 +0,0 @@
-
-import os, os.path
-import copy, glob, sys
-import sipconfig
-import PyQt4.pyqtconfig
-
-src_path = '@CMAKE_SOURCE_DIR@'
-build_path = '@CMAKE_BINARY_DIR@'
-python_path = src_path + '/python'
-gdal_inc_dir = '@GDAL_INCLUDE_DIR@'
-geos_inc_dir = '@GEOS_INCLUDE_DIR@'
-
-qt_libs = ["QtCore","QtGui","QtNetwork","QtSvg","QtXml"]
-if sys.platform == 'darwin':
- qt_libs.append("QtSql")
- # possibility of universal build of bindings, if more than 1 arch
- osx_archs = '@CMAKE_OSX_ARCHITECTURES@'
- osx_archs = osx_archs.strip(';')
- if osx_archs.count(';') > 0:
- osx_universal = '@CMAKE_OSX_SYSROOT@'
- else:
- osx_universal = ''
-else:
- osx_universal = ''
-
-if len(sys.argv)>1:
- intdir = "/" + sys.argv[1]
-else:
- intdir = ""
-
-if len(sys.argv)>2:
- export = sys.argv[2]
-else:
- export = ""
-
-# create paths for temporary files if don't exist
-if not os.path.isdir("./core"):
- os.mkdir("./core")
-if not os.path.isdir("./gui"):
- os.mkdir("./gui")
-if not os.path.isdir("./analysis"):
- os.mkdir("./analysis")
-
-##########################################################################
-# SIP -> *.CPP + *.H
-
-# The name of the SIP build file generated by SIP and used by the build
-# system.
-build_file_core = build_path + "/python/core/core.sbf"
-build_file_gui = build_path + "/python/gui/gui.sbf"
-build_file_analysis = build_path + "/python/analysis/analysis.sbf"
-
-# Get the SIP configuration information.
-config = PyQt4.pyqtconfig.Configuration()
-
-# Get the extra SIP flags needed by the imported qt module. Note that
-# this normally only includes those flags (-x and -t) that relate to SIP's
-# versioning system.
-qt_sip_flags = config.pyqt_sip_flags
-
-# directory where modules will be installed
-mod_dir = os.path.join(config.default_mod_dir, "qgis")
-
-# directory where sip files will be installed
-sip_dir_core = os.path.join(config.default_sip_dir, "qgis/core")
-sip_dir_gui = os.path.join(config.default_sip_dir, "qgis/gui")
-sip_dir_analysis = os.path.join(config.default_sip_dir, "qgis/analysis")
-
-# Run SIP to generate the code.
-print "Parsing SIP files for 'core' library..."
-cmd = " ".join([config.sip_bin, "-c", "core", "-b", build_file_core, "-I", config.pyqt_sip_dir, qt_sip_flags, python_path + "/core/core.sip"])
-print cmd
-os.system(cmd)
-
-print "Parsing SIP files for 'gui' library..."
-cmd = " ".join([config.sip_bin, "-c", "gui", "-b", build_file_gui, "-I", python_path, "-I", config.pyqt_sip_dir, qt_sip_flags, python_path + "/gui/gui.sip"])
-print cmd
-os.system(cmd)
-
-print "Parsing SIP files for 'analysis' library..."
-cmd = " ".join([config.sip_bin, "-c", "analysis", "-b", build_file_analysis, "-I", python_path, "-I", config.pyqt_sip_dir, qt_sip_flags, python_path + "/analysis/analysis.sip"])
-print cmd
-os.system(cmd)
-
-
-##########################################################################
-# MAKEFILES
-
-print "Creating makefiles..."
-
-# We are going to install the SIP specification file for this module and
-# its configuration module.
-installs = []
-
-# directories relative to core (gui, analysis) directories
-installs.append([[python_path + "__init__.py", python_path + "qgisconfig.py"], mod_dir])
-
-
-installs_core = copy.copy(installs)
-installs_gui = copy.copy(installs)
-installs_analysis = copy.copy(installs)
-
-# install all sip files
-sips_core = glob.glob(python_path + "/core/*.sip")
-for sip in sips_core:
- installs_core.append([os.path.basename(sip), sip_dir_core])
-
-sips_gui = glob.glob(python_path + "/gui/*.sip")
-for sip in sips_gui:
- installs_gui.append([os.path.basename(sip), sip_dir_gui])
-
-sips_analysis = glob.glob(python_path + "/analysis/*.sip")
-for sip in sips_analysis:
- installs_analysis.append([os.path.basename(sip), sip_dir_analysis])
-
-
-# Create the Makefile. The QtModuleMakefile class provided by the
-# pyqtconfig module takes care of all the extra preprocessor, compiler and
-# linker flags needed by the Qt library.
-makefile_core = sipconfig.ModuleMakefile(
- configuration=config,
- qt=qt_libs,
- build_file=build_file_core,
- installs=installs_core,
- install_dir=mod_dir,
- dir="core",
- universal=osx_universal)
-
-makefile_gui = sipconfig.ModuleMakefile(
- configuration=config,
- qt=qt_libs,
- build_file=build_file_gui,
- installs=installs_gui,
- install_dir=mod_dir,
- dir="gui",
- universal=osx_universal)
-
-makefile_analysis = sipconfig.ModuleMakefile(
- configuration=config,
- qt=qt_libs,
- build_file=build_file_analysis,
- installs=installs_analysis,
- install_dir=mod_dir,
- dir="analysis",
- universal=osx_universal)
-
-# common settings for core, gui and analysis libs
-for mk in [ makefile_core, makefile_gui, makefile_analysis ]:
- mk.extra_lflags.extend( "@CMAKE_MODULE_LINKER_FLAGS@".strip(' ').split(' ') )
- mk.extra_libs = ["qgis_core"]
- mk.extra_lib_dirs = [build_path+"/src/core"+intdir]
- mk.extra_include_dirs = [src_path+"/src/core", src_path+"/src/core/composer",
- src_path+"/src/core/raster",
- src_path+"/src/core/renderer",
- src_path+"/src/core/spatialindex",
- src_path+"/src/core/symbology",
- src_path+"/src/core/symbology-ng",
- build_path, # qgsconfig.h, qgssvnversion.h
- gdal_inc_dir,
- geos_inc_dir]
- mk.extra_cxxflags = ["-DCORE_EXPORT="+export]
-
-# more settings for gui lib
-makefile_gui.extra_libs.append("qgis_gui")
-makefile_gui.extra_lib_dirs.append(build_path+"/src/gui"+intdir)
-makefile_gui.extra_include_dirs.append(src_path+"/src/gui")
-makefile_gui.extra_include_dirs.append(src_path+"/src/gui/symbology-ng")
-makefile_gui.extra_include_dirs.append(build_path+"/src/gui")
-makefile_gui.extra_include_dirs.append(build_path+"/src/ui")
-makefile_gui.extra_include_dirs.append(src_path+"/src/plugins") # because of qgisplugin.h TODO: sort out
-makefile_gui.extra_cxxflags.append("-DGUI_EXPORT="+export)
-
-# more settings for analysis lib
-makefile_analysis.extra_libs.append("qgis_analysis")
-makefile_analysis.extra_lib_dirs.append(build_path+"/src/analysis"+intdir)
-makefile_analysis.extra_include_dirs.append(src_path+"/src/analysis/vector")
-makefile_analysis.extra_include_dirs.append(build_path+"/src/analysis/vector")
-makefile_analysis.extra_include_dirs.append(src_path+"/src/plugins") # because of qgisplugin.h TODO: sort out
-makefile_analysis.extra_cxxflags.append("-DANALYSIS_EXPORT="+export)
-
-# Generate the Makefile itself.
-makefile_core.generate()
-makefile_gui.generate()
-makefile_analysis.generate()
-
-##########################################################################
-# QGIS CONFIG
-
-print "Creating qgisconfig.py..."
-
-# Now we create the configuration module. This is done by merging a Python
-# dictionary (whose values are normally determined dynamically) with a
-# (static) template.
-content = {
- # Publish where the SIP specifications for this module will be
- # installed.
- "qgis_sip_dir": config.default_sip_dir,
-
- "qgis_mod_dir": mod_dir,
-
- # Publish the set of SIP flags needed by this module. As these are the
- # same flags needed by the qt module we could leave it out, but this
- # allows us to change the flags at a later date without breaking
- # scripts that import the configuration module.
- "qgis_sip_flags": qt_sip_flags
-}
-
-# This creates the qgisconfig.py module from the qgisconfig.py.in
-# template and the dictionary.
-sipconfig.create_config_module(build_path+"/python/qgisconfig.py", src_path+"/python/qgisconfig.py.in", content)
-
-print "Done"
-
Deleted: trunk/qgis/python/qgisconfig.py.in
===================================================================
--- trunk/qgis/python/qgisconfig.py.in 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/python/qgisconfig.py.in 2010-01-16 11:04:41 UTC (rev 12774)
@@ -1,40 +0,0 @@
-import PyQt4.pyqtconfig
-
-# These are installation specific values created when QGIS was configured.
-# The following line will be replaced when this template is used to create
-# the final configuration module.
-# @SIP_CONFIGURATION@
-
-class Configuration(pyqtconfig.Configuration):
- """The class that represents QGIS configuration values.
- """
- def __init__(self, sub_cfg=None):
- """Initialise an instance of the class.
-
- sub_cfg is the list of sub-class configurations. It should be None
- when called normally.
- """
- # This is all standard code to be copied verbatim except for the
- # name of the module containing the super-class.
- if sub_cfg:
- cfg = sub_cfg
- else:
- cfg = []
-
- cfg.append(_pkg_config)
-
- pyqtconfig.Configuration.__init__(self, cfg)
-
-class QgisModuleMakefile(pyqtconfig.QtModuleMakefile):
- """The Makefile class for modules that %Import qgis_core.
- """
- def finalise(self):
- """Finalise the macros.
- """
- # Make sure our C++ library is linked.
- self.extra_libs.append("qgis_core")
- self.extra_libs.append("qgis_gui")
- self.extra_libs.append("qgis_analysis")
-
- # Let the super-class do what it needs to.
- pyqtconfig.QtModuleMakefile.finalise(self)
Modified: trunk/qgis/src/CMakeLists.txt
===================================================================
--- trunk/qgis/src/CMakeLists.txt 2010-01-16 01:05:44 UTC (rev 12773)
+++ trunk/qgis/src/CMakeLists.txt 2010-01-16 11:04:41 UTC (rev 12774)
@@ -1,9 +1,9 @@
SUBDIRS(core analysis ui gui app providers plugins helpviewer)
-IF (HAVE_PYTHON AND WITH_BINDINGS)
+IF (WITH_BINDINGS)
SUBDIRS(python)
-ENDIF (HAVE_PYTHON AND WITH_BINDINGS)
+ENDIF (WITH_BINDINGS)
IF (APPLE)
SUBDIRS(mac)
More information about the QGIS-commit
mailing list