Skip to content
Permalink
Browse files

Add CMake finds for QScintilla2 and Qsci module

- Needs testing on Windows platform
- Add QScintilla2 library version info to About dialog
- Add Mac bundling support for Qwt 6 framework and QScintilla2
- Fallback to sys or custom site-pkgs when looking for PyQt4 modules to Mac bundle
  • Loading branch information
dakcarto committed Oct 23, 2012
1 parent 332ce32 commit e8edb950e4b499a9411cfcfcb109a3dc5b18bdc7
@@ -229,6 +229,16 @@ ELSE (WITH_TOUCH)
MESSAGE (STATUS "Touch support disabled")
ENDIF (WITH_TOUCH)

# search for QScintilla2 (C++ lib)
IF (WITH_BINDINGS)
# TODO: make required after testing find paths on Windows platforms
#FIND_PACKAGE(QScintilla REQUIRED)
FIND_PACKAGE(QScintilla)
ELSE (WITH_BINDINGS)
# for when library is used in .h/cpp
FIND_PACKAGE(QScintilla)
ENDIF (WITH_BINDINGS)

IF (ENABLE_TESTS)
SET( QT_USE_QTTEST TRUE )
ENABLE_TESTING()
@@ -497,6 +507,7 @@ IF (WITH_BINDINGS)
FIND_PACKAGE(PythonLibrary REQUIRED)
FIND_PACKAGE(SIP REQUIRED)
FIND_PACKAGE(PyQt4 REQUIRED)
FIND_PACKAGE(Qsci REQUIRED)
INCLUDE(PythonMacros)
INCLUDE(SIPMacros)
INCLUDE(PyQt4Macros)
@@ -513,6 +524,11 @@ IF (WITH_BINDINGS)

ENDIF (WITH_BINDINGS)

# Set QSCINTILLA_VERSION_STR to that of module, if no headers found
IF (NOT EXISTS QSCINTILLA_VERSION_STR AND EXISTS QSCI_MOD_VERSION_STR)
SET(QSCINTILLA_VERSION_STR ${QSCI_MOD_VERSION_STR})
ENDIF (NOT EXISTS QSCINTILLA_VERSION_STR AND EXISTS QSCI_MOD_VERSION_STR)

#############################################################
# create qgsconfig.h
# installed with app target
@@ -49,6 +49,7 @@
in_t = False
print("pyqt_version_tag:%s" % pyqt_version_tag)

print("pyqt_mod_dir:%s" % pyqtcfg.pyqt_mod_dir)
print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
print("pyqt_bin_dir:%s" % pyqtcfg.pyqt_bin_dir)
@@ -35,6 +35,7 @@ ELSE(EXISTS PYQT4_VERSION)
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_version_num:([^\n]+).*$" "\\1" PYQT4_VERSION_NUM ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_mod_dir:([^\n]+).*$" "\\1" PYQT4_MOD_DIR ${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})
STRING(REGEX REPLACE ".*\npyqt_bin_dir:([^\n]+).*$" "\\1" PYQT4_BIN_DIR ${pyqt_config})
@@ -79,6 +79,11 @@ else(EXISTS PYTHON_LIBRARY)
endif(PYTHONINTERP_FOUND)

if(PYTHONLIBRARY_FOUND)
if(APPLE)
# keep reference to system or custom python site-packages
# useful during app-bundling operations
set(PYTHON_SITE_PACKAGES_SYS ${PYTHON_SITE_PACKAGES_DIR})
endif(APPLE)
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
if(NOT PYTHONLIBRARY_FIND_QUIETLY)
message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
@@ -0,0 +1,78 @@
# Find QScintilla2 PyQt4 module
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# QScintilla2 website: http://www.riverbankcomputing.co.uk/software/qscintilla/
#
# Try to find the QScintilla2 includes and library
# which defines
#
# QSCINTILLA_FOUND - system has QScintilla2
# QSCINTILLA_INCLUDE_DIR - where to find qextscintilla.h
# QSCINTILLA_LIBRARY - where to find the QScintilla2 library
# QSCINTILLA_VERSION_STR - version of library

# copyright (c) 2007 Thomas Moenicke thomas.moenicke@kdemail.net
#
# Redistribution and use is allowed according to the terms of the FreeBSD license.

# Edited by Larry Shaffer, 2012
# NOTE: include after check for Qt


IF(EXISTS QSCINTILLA_VERSION_STR)
# Already in cache, be silent
SET(QSCINTILLA_FOUND TRUE)
ELSE(EXISTS QSCINTILLA_VERSION_STR)

FIND_PATH(QSCINTILLA_INCLUDE_DIR
NAMES qsciglobal.h
PATHS
"${QT_INCLUDE_DIR}/Qsci"
/usr/include
/usr/include/Qsci
/usr/local/include/Qsci
)

FIND_LIBRARY(QSCINTILLA_LIBRARY
NAMES qscintilla2 libqscintilla2 libqscintilla2.dylib
PATHS
"${QT_LIBRARY_DIR}"
/usr/lib
/usr/local/lib
)

IF(QSCINTILLA_LIBRARY)
# QSCINTILLA_INCLUDE_DIR is not required at this time (Oct 2012) since only
# Qsci PyQt4 module is used, though lib is needed for Mac bundling
SET(QSCINTILLA_FOUND TRUE)

IF(CYGWIN)
IF(BUILD_SHARED_LIBS)
# No need to define QSCINTILLA_USE_DLL here, because it's default for Cygwin.
ELSE(BUILD_SHARED_LIBS)
SET (QSCINTILLA_DEFINITIONS -DQSCINTILLA_STATIC)
ENDIF(BUILD_SHARED_LIBS)
ENDIF(CYGWIN)
ENDIF(QSCINTILLA_LIBRARY)

IF(QSCINTILLA_INCLUDE_DIR AND NOT EXISTS QSCINTILLA_VERSION_STR)
# get QScintilla2 version from header, is optinally retrieved via bindings
# with Qsci PyQt4 module
FILE(READ ${QSCINTILLA_INCLUDE_DIR}/qsciglobal.h qsci_header)
STRING(REGEX REPLACE "^.*QSCINTILLA_VERSION_STR +\"([^\"]+)\".*$" "\\1" QSCINTILLA_VERSION_STR "${qsci_header}")
ENDIF(QSCINTILLA_INCLUDE_DIR AND NOT EXISTS QSCINTILLA_VERSION_STR)

IF(QSCINTILLA_FOUND)
IF(NOT QSCINTILLA_FIND_QUIETLY)
MESSAGE(STATUS "Found QScintilla2: ${QSCINTILLA_LIBRARY} (${QSCINTILLA_VERSION_STR})")
ENDIF(NOT QSCINTILLA_FIND_QUIETLY)
ELSE(QSCINTILLA_FOUND)
IF(QSCINTILLA_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QScintilla2 library")
ENDIF(QSCINTILLA_FIND_REQUIRED)
ENDIF(QSCINTILLA_FOUND)

ENDIF(EXISTS QSCINTILLA_VERSION_STR)

#MARK_AS_ADVANCED(QSCINTILLA_INCLUDE_DIR QSCINTILLA_LIBRARY)

@@ -0,0 +1,43 @@
# Find QScintilla2 PyQt4 module
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# QScintilla2 website: http://www.riverbankcomputing.co.uk/software/qscintilla/
#
# Find the installed version of QScintilla2 module. FindQsci should be called
# after Python has been found.
#
# This file defines the following variables:
#
# QSCI_FOUND - system has QScintilla2 PyQt4 module
#
# QSCI_MOD_VERSION_STR - The version of Qsci module as a human readable string.
#
# Copyright (c) 2012, Larry Shaffer <larrys@dakotacarto.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

IF(EXISTS QSCI_MOD_VERSION_STR)
# Already in cache, be silent
SET(QSCI_FOUND TRUE)
ELSE(EXISTS QSCI_MOD_VERSION_STR)

FIND_FILE(_find_qsci_py FindQsci.py PATHS ${CMAKE_MODULE_PATH})

EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_qsci_py} OUTPUT_VARIABLE qsci_ver)

IF(qsci_ver)
STRING(REGEX REPLACE "^qsci_version_str:([^\n]+).*$" "\\1" QSCI_MOD_VERSION_STR ${qsci_ver})
SET(QSCI_FOUND TRUE)
ENDIF(qsci_ver)

IF(QSCI_FOUND)
IF(NOT QSCI_FIND_QUIETLY)
MESSAGE(STATUS "Found QScintilla2 PyQt4 module: ${QSCI_MOD_VERSION_STR}")
ENDIF(NOT QSCI_FIND_QUIETLY)
ELSE(QSCI_FOUND)
IF(QSCI_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QScintilla2 PyQt4 module")
ENDIF(QSCI_FIND_REQUIRED)
ENDIF(QSCI_FOUND)

ENDIF(EXISTS QSCI_MOD_VERSION_STR)
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""Find QScintilla2 PyQt4 module version.
.. note:: Redistribution and use is allowed according to the terms of the BSD
license. For details see the accompanying COPYING-CMAKE-SCRIPTS file.
"""
__author__ = 'Larry Shaffer (larry@dakotacarto.com)'
__date__ = '22/10/2012'
__copyright__ = 'Copyright 2012, The Quantum GIS Project'


try:
from PyQt4.Qsci import QSCINTILLA_VERSION_STR
VER = QSCINTILLA_VERSION_STR
except ImportError, e:
VER = ""


print("qsci_version_str:%s" % VER)
@@ -1,3 +1,10 @@
# Concatenation/editing of QScintilla API files for PyQGIS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2012, Larry Shaffer <larrys@dakotacarto.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

SET(QGIS_PYTHON_API_FILE "${CMAKE_BINARY_DIR}/python/qsci_apis/PyQGIS.api")

IF(EXISTS "${CMAKE_BINARY_DIR}/python/qgis.gui.api")
@@ -28,6 +28,8 @@
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}"

#define QSCINTILLA_VERSION_STR "${QSCINTILLA_VERSION_STR}"

#cmakedefine HAVE_POSTGRESQL

#cmakedefine HAVE_SPATIALITE

0 comments on commit e8edb95

Please sign in to comment.
You can’t perform that action at this time.