Skip to content

Commit e8edb95

Browse files
committed
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
1 parent 332ce32 commit e8edb95

11 files changed

+293
-22
lines changed

CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ ELSE (WITH_TOUCH)
229229
MESSAGE (STATUS "Touch support disabled")
230230
ENDIF (WITH_TOUCH)
231231

232+
# search for QScintilla2 (C++ lib)
233+
IF (WITH_BINDINGS)
234+
# TODO: make required after testing find paths on Windows platforms
235+
#FIND_PACKAGE(QScintilla REQUIRED)
236+
FIND_PACKAGE(QScintilla)
237+
ELSE (WITH_BINDINGS)
238+
# for when library is used in .h/cpp
239+
FIND_PACKAGE(QScintilla)
240+
ENDIF (WITH_BINDINGS)
241+
232242
IF (ENABLE_TESTS)
233243
SET( QT_USE_QTTEST TRUE )
234244
ENABLE_TESTING()
@@ -497,6 +507,7 @@ IF (WITH_BINDINGS)
497507
FIND_PACKAGE(PythonLibrary REQUIRED)
498508
FIND_PACKAGE(SIP REQUIRED)
499509
FIND_PACKAGE(PyQt4 REQUIRED)
510+
FIND_PACKAGE(Qsci REQUIRED)
500511
INCLUDE(PythonMacros)
501512
INCLUDE(SIPMacros)
502513
INCLUDE(PyQt4Macros)
@@ -513,6 +524,11 @@ IF (WITH_BINDINGS)
513524

514525
ENDIF (WITH_BINDINGS)
515526

527+
# Set QSCINTILLA_VERSION_STR to that of module, if no headers found
528+
IF (NOT EXISTS QSCINTILLA_VERSION_STR AND EXISTS QSCI_MOD_VERSION_STR)
529+
SET(QSCINTILLA_VERSION_STR ${QSCI_MOD_VERSION_STR})
530+
ENDIF (NOT EXISTS QSCINTILLA_VERSION_STR AND EXISTS QSCI_MOD_VERSION_STR)
531+
516532
#############################################################
517533
# create qgsconfig.h
518534
# installed with app target

cmake/FindPyQt.py

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
in_t = False
5050
print("pyqt_version_tag:%s" % pyqt_version_tag)
5151

52+
print("pyqt_mod_dir:%s" % pyqtcfg.pyqt_mod_dir)
5253
print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
5354
print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
5455
print("pyqt_bin_dir:%s" % pyqtcfg.pyqt_bin_dir)

cmake/FindPyQt4.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ELSE(EXISTS PYQT4_VERSION)
3535
STRING(REGEX REPLACE ".*\npyqt_version_str:([^\n]+).*$" "\\1" PYQT4_VERSION_STR ${pyqt_config})
3636
STRING(REGEX REPLACE ".*\npyqt_version_tag:([^\n]+).*$" "\\1" PYQT4_VERSION_TAG ${pyqt_config})
3737
STRING(REGEX REPLACE ".*\npyqt_version_num:([^\n]+).*$" "\\1" PYQT4_VERSION_NUM ${pyqt_config})
38+
STRING(REGEX REPLACE ".*\npyqt_mod_dir:([^\n]+).*$" "\\1" PYQT4_MOD_DIR ${pyqt_config})
3839
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT4_SIP_DIR ${pyqt_config})
3940
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT4_SIP_FLAGS ${pyqt_config})
4041
STRING(REGEX REPLACE ".*\npyqt_bin_dir:([^\n]+).*$" "\\1" PYQT4_BIN_DIR ${pyqt_config})

cmake/FindPythonLibrary.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ else(EXISTS PYTHON_LIBRARY)
7979
endif(PYTHONINTERP_FOUND)
8080

8181
if(PYTHONLIBRARY_FOUND)
82+
if(APPLE)
83+
# keep reference to system or custom python site-packages
84+
# useful during app-bundling operations
85+
set(PYTHON_SITE_PACKAGES_SYS ${PYTHON_SITE_PACKAGES_DIR})
86+
endif(APPLE)
8287
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY})
8388
if(NOT PYTHONLIBRARY_FIND_QUIETLY)
8489
message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")

cmake/FindQScintilla.cmake

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Find QScintilla2 PyQt4 module
2+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
#
4+
# QScintilla2 website: http://www.riverbankcomputing.co.uk/software/qscintilla/
5+
#
6+
# Try to find the QScintilla2 includes and library
7+
# which defines
8+
#
9+
# QSCINTILLA_FOUND - system has QScintilla2
10+
# QSCINTILLA_INCLUDE_DIR - where to find qextscintilla.h
11+
# QSCINTILLA_LIBRARY - where to find the QScintilla2 library
12+
# QSCINTILLA_VERSION_STR - version of library
13+
14+
# copyright (c) 2007 Thomas Moenicke thomas.moenicke@kdemail.net
15+
#
16+
# Redistribution and use is allowed according to the terms of the FreeBSD license.
17+
18+
# Edited by Larry Shaffer, 2012
19+
# NOTE: include after check for Qt
20+
21+
22+
IF(EXISTS QSCINTILLA_VERSION_STR)
23+
# Already in cache, be silent
24+
SET(QSCINTILLA_FOUND TRUE)
25+
ELSE(EXISTS QSCINTILLA_VERSION_STR)
26+
27+
FIND_PATH(QSCINTILLA_INCLUDE_DIR
28+
NAMES qsciglobal.h
29+
PATHS
30+
"${QT_INCLUDE_DIR}/Qsci"
31+
/usr/include
32+
/usr/include/Qsci
33+
/usr/local/include/Qsci
34+
)
35+
36+
FIND_LIBRARY(QSCINTILLA_LIBRARY
37+
NAMES qscintilla2 libqscintilla2 libqscintilla2.dylib
38+
PATHS
39+
"${QT_LIBRARY_DIR}"
40+
/usr/lib
41+
/usr/local/lib
42+
)
43+
44+
IF(QSCINTILLA_LIBRARY)
45+
# QSCINTILLA_INCLUDE_DIR is not required at this time (Oct 2012) since only
46+
# Qsci PyQt4 module is used, though lib is needed for Mac bundling
47+
SET(QSCINTILLA_FOUND TRUE)
48+
49+
IF(CYGWIN)
50+
IF(BUILD_SHARED_LIBS)
51+
# No need to define QSCINTILLA_USE_DLL here, because it's default for Cygwin.
52+
ELSE(BUILD_SHARED_LIBS)
53+
SET (QSCINTILLA_DEFINITIONS -DQSCINTILLA_STATIC)
54+
ENDIF(BUILD_SHARED_LIBS)
55+
ENDIF(CYGWIN)
56+
ENDIF(QSCINTILLA_LIBRARY)
57+
58+
IF(QSCINTILLA_INCLUDE_DIR AND NOT EXISTS QSCINTILLA_VERSION_STR)
59+
# get QScintilla2 version from header, is optinally retrieved via bindings
60+
# with Qsci PyQt4 module
61+
FILE(READ ${QSCINTILLA_INCLUDE_DIR}/qsciglobal.h qsci_header)
62+
STRING(REGEX REPLACE "^.*QSCINTILLA_VERSION_STR +\"([^\"]+)\".*$" "\\1" QSCINTILLA_VERSION_STR "${qsci_header}")
63+
ENDIF(QSCINTILLA_INCLUDE_DIR AND NOT EXISTS QSCINTILLA_VERSION_STR)
64+
65+
IF(QSCINTILLA_FOUND)
66+
IF(NOT QSCINTILLA_FIND_QUIETLY)
67+
MESSAGE(STATUS "Found QScintilla2: ${QSCINTILLA_LIBRARY} (${QSCINTILLA_VERSION_STR})")
68+
ENDIF(NOT QSCINTILLA_FIND_QUIETLY)
69+
ELSE(QSCINTILLA_FOUND)
70+
IF(QSCINTILLA_FIND_REQUIRED)
71+
MESSAGE(FATAL_ERROR "Could not find QScintilla2 library")
72+
ENDIF(QSCINTILLA_FIND_REQUIRED)
73+
ENDIF(QSCINTILLA_FOUND)
74+
75+
ENDIF(EXISTS QSCINTILLA_VERSION_STR)
76+
77+
#MARK_AS_ADVANCED(QSCINTILLA_INCLUDE_DIR QSCINTILLA_LIBRARY)
78+

cmake/FindQsci.cmake

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Find QScintilla2 PyQt4 module
2+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
#
4+
# QScintilla2 website: http://www.riverbankcomputing.co.uk/software/qscintilla/
5+
#
6+
# Find the installed version of QScintilla2 module. FindQsci should be called
7+
# after Python has been found.
8+
#
9+
# This file defines the following variables:
10+
#
11+
# QSCI_FOUND - system has QScintilla2 PyQt4 module
12+
#
13+
# QSCI_MOD_VERSION_STR - The version of Qsci module as a human readable string.
14+
#
15+
# Copyright (c) 2012, Larry Shaffer <larrys@dakotacarto.com>
16+
# Redistribution and use is allowed according to the terms of the BSD license.
17+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
18+
19+
IF(EXISTS QSCI_MOD_VERSION_STR)
20+
# Already in cache, be silent
21+
SET(QSCI_FOUND TRUE)
22+
ELSE(EXISTS QSCI_MOD_VERSION_STR)
23+
24+
FIND_FILE(_find_qsci_py FindQsci.py PATHS ${CMAKE_MODULE_PATH})
25+
26+
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${_find_qsci_py} OUTPUT_VARIABLE qsci_ver)
27+
28+
IF(qsci_ver)
29+
STRING(REGEX REPLACE "^qsci_version_str:([^\n]+).*$" "\\1" QSCI_MOD_VERSION_STR ${qsci_ver})
30+
SET(QSCI_FOUND TRUE)
31+
ENDIF(qsci_ver)
32+
33+
IF(QSCI_FOUND)
34+
IF(NOT QSCI_FIND_QUIETLY)
35+
MESSAGE(STATUS "Found QScintilla2 PyQt4 module: ${QSCI_MOD_VERSION_STR}")
36+
ENDIF(NOT QSCI_FIND_QUIETLY)
37+
ELSE(QSCI_FOUND)
38+
IF(QSCI_FIND_REQUIRED)
39+
MESSAGE(FATAL_ERROR "Could not find QScintilla2 PyQt4 module")
40+
ENDIF(QSCI_FIND_REQUIRED)
41+
ENDIF(QSCI_FOUND)
42+
43+
ENDIF(EXISTS QSCI_MOD_VERSION_STR)

cmake/FindQsci.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
"""Find QScintilla2 PyQt4 module version.
3+
4+
.. note:: Redistribution and use is allowed according to the terms of the BSD
5+
license. For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6+
"""
7+
__author__ = 'Larry Shaffer (larry@dakotacarto.com)'
8+
__date__ = '22/10/2012'
9+
__copyright__ = 'Copyright 2012, The Quantum GIS Project'
10+
11+
12+
try:
13+
from PyQt4.Qsci import QSCINTILLA_VERSION_STR
14+
VER = QSCINTILLA_VERSION_STR
15+
except ImportError, e:
16+
VER = ""
17+
18+
19+
print("qsci_version_str:%s" % VER)

cmake/QsciAPI.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# Concatenation/editing of QScintilla API files for PyQGIS
2+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
#
4+
# Copyright (c) 2012, Larry Shaffer <larrys@dakotacarto.com>
5+
# Redistribution and use is allowed according to the terms of the BSD license.
6+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
7+
18
SET(QGIS_PYTHON_API_FILE "${CMAKE_BINARY_DIR}/python/qsci_apis/PyQGIS.api")
29

310
IF(EXISTS "${CMAKE_BINARY_DIR}/python/qgis.gui.api")

cmake_templates/qgsconfig.h.in

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#define CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
2929
#define CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}"
3030

31+
#define QSCINTILLA_VERSION_STR "${QSCINTILLA_VERSION_STR}"
32+
3133
#cmakedefine HAVE_POSTGRESQL
3234

3335
#cmakedefine HAVE_SPATIALITE

0 commit comments

Comments
 (0)