Skip to content

Commit d712b49

Browse files
authored
Merge pull request #3790 from dakcarto/qt5py3-mac-fixes
Qt5py3 Mac fixes
2 parents 311f482 + eca83e3 commit d712b49

21 files changed

+116
-65
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ IF (WITH_BINDINGS)
105105
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
106106
# keep casual users from updating their source tree via WITH_QSCIAPI
107107
MARK_AS_ADVANCED (WITH_QSCIAPI)
108-
# path to custom Python framework on Mac
109-
IF (APPLE)
110-
SET (PYTHON_CUSTOM_FRAMEWORK "" CACHE PATH "Path to custom Python.framework on Mac. (should not have to specify other Python options)")
111-
ENDIF (APPLE)
112108
ENDIF (WITH_BINDINGS)
113109

114110
#BUILD WITH QtMobility by default on android only. Other platform can force it

cmake/CMakeDebugMacros.cmake

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Macros/functions for debugging CMake
2+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
#
4+
# Copyright (c) 2016, Larry Shaffer, <lshaffer (at) boundlessgeo (dot) 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+
8+
9+
# Dump current CMake variables to file
10+
#
11+
# Usage:
12+
# INCLUDE(CMakeDebugMacros)
13+
# DUMP_CMAKE_VARS() or DUMP_CMAKE_VARS("regex")
14+
#
15+
# regex: optional ARGV0 regular expression for filtering output variable names
16+
#
17+
# Outputs the result relative to the current CMake file being processed and
18+
# writes to a file with name "<file-basename>_cmake-vars.txt" to the current
19+
# build (binary) directory
20+
#
21+
function(DUMP_CMAKE_VARS)
22+
23+
get_filename_component(_basename ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
24+
set(_out "${CMAKE_CURRENT_BINARY_DIR}/${_basename}_cmake-vars.txt")
25+
26+
set(_cmake_vars "")
27+
get_cmake_property(_varNames VARIABLES)
28+
foreach(_varName ${_varNames})
29+
if(ARGV0)
30+
string(REGEX MATCH "${ARGV0}" _match "${_varName}")
31+
if(_match)
32+
set(_cmake_vars "${_cmake_vars}\n\n${_varName}=${${_varName}}")
33+
endif()
34+
else()
35+
set(_cmake_vars "${_cmake_vars}\n\n${_varName}=${${_varName}}")
36+
endif()
37+
endforeach()
38+
39+
message(STATUS "Dumping current CMake variables to ...\n ${_out}")
40+
file(WRITE "${_out}" "${_cmake_vars}")
41+
42+
endfunction(DUMP_CMAKE_VARS)

cmake/FindPyQt5.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ ELSE(EXISTS PYQT5_VERSION)
3737
STRING(REGEX REPLACE ".*\npyqt_version_num:([^\n]+).*$" "\\1" PYQT5_VERSION_NUM ${pyqt_config})
3838
STRING(REGEX REPLACE ".*\npyqt_mod_dir:([^\n]+).*$" "\\1" PYQT5_MOD_DIR ${pyqt_config})
3939
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT5_SIP_DIR ${pyqt_config})
40+
IF(EXISTS ${PYQT5_SIP_DIR}/Qt5)
41+
SET(PYQT5_SIP_DIR ${PYQT5_SIP_DIR}/Qt5)
42+
ENDIF(EXISTS ${PYQT5_SIP_DIR}/Qt5)
4043
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT5_SIP_FLAGS ${pyqt_config})
4144
STRING(REGEX REPLACE ".*\npyqt_bin_dir:([^\n]+).*$" "\\1" PYQT5_BIN_DIR ${pyqt_config})
4245

cmake/FindPythonLibrary.cmake

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ if(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "${
3131
set(PYTHONLIBRARY_FOUND TRUE)
3232
else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "${PYTHON_SITE_PACKAGES_DIR}")
3333

34-
set(_custom_python_fw FALSE)
35-
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
36-
if("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
37-
STRING(REGEX REPLACE "(.*Python\\.framework).*$" "\\1" _python_fw "${PYTHON_CUSTOM_FRAMEWORK}")
38-
set(PYTHON_EXECUTABLE "${_python_fw}/Versions/Current/bin/python")
39-
set(PYTHON_INCLUDE_PATH "${_python_fw}/Versions/Current/Headers")
40-
set(PYTHON_LIBRARY "${_python_fw}/Versions/Current/Python")
41-
if(EXISTS "${PYTHON_EXECUTABLE}" AND EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
42-
set(_custom_python_fw TRUE)
43-
endif()
44-
endif("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
45-
endif(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
46-
4734
FIND_PACKAGE(PythonInterp 3)
4835

4936
if(PYTHONINTERP_FOUND)
@@ -74,22 +61,39 @@ else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "
7461
endif(python_config)
7562

7663
# adapted from cmake's builtin FindPythonLibs
77-
if(APPLE AND NOT _custom_python_fw)
78-
CMAKE_FIND_FRAMEWORKS(Python)
79-
set(PYTHON_FRAMEWORK_INCLUDES)
80-
if(Python_FRAMEWORKS)
81-
# If a framework has been selected for the include path,
82-
# make sure "-framework" is used to link it.
64+
if(APPLE)
65+
# If a framework has been detected in the include path, make sure
66+
# framework's versioned library (not any .dylib) is used for linking
67+
# NOTE: don't rely upon Python.framework/Versions/Current, since that may be 2.7
8368
if("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
8469
set(PYTHON_LIBRARY "")
8570
set(PYTHON_DEBUG_LIBRARY "")
71+
# get clean path to just framework
72+
STRING(REGEX REPLACE "^(.*/Python\\.framework).*$" "\\1" _py_fw "${PYTHON_INCLUDE_PATH}")
73+
if("${_py_fw}" MATCHES "Cellar/python")
74+
# Appears to be a Homebrew Python install; do specific fix ups
75+
# get Homebrew prefix (may not be /usr/local)
76+
STRING(REGEX REPLACE "^(.+)/Cellar.*$" "\\1" _hb_prefix "${_py_fw}")
77+
# prefer the Homebrew prefix framework over only versioned Python keg
78+
set(_py_fw "${_hb_prefix}/Frameworks/Python.framework")
79+
# prefer the symlinked-to Homebrew site-packages over only versioned Python keg
80+
set(PYTHON_SITE_PACKAGES_DIR "${_hb_prefix}/lib/python${PYTHON_SHORT_VERSION}/site-packages")
81+
endif("${_py_fw}" MATCHES "Cellar/python")
82+
# prefer the Headers subdirectory for includes
83+
if(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers")
84+
set(PYTHON_INCLUDE_PATH "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
85+
endif(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers")
8686
endif("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
8787
if(NOT PYTHON_LIBRARY)
88-
set (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
88+
# ensure the versioned framework's library is defined, instead of relying upon -F search paths
89+
if(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python")
90+
set(PYTHON_LIBRARY "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python" CACHE FILEPATH "Python framework library" FORCE)
91+
endif(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python")
8992
endif(NOT PYTHON_LIBRARY)
90-
set(PYTHONLIBRARY_FOUND TRUE)
91-
endif(Python_FRAMEWORKS)
92-
endif(APPLE AND NOT _custom_python_fw)
93+
if(PYTHON_LIBRARY)
94+
set(PYTHONLIBRARY_FOUND TRUE)
95+
endif(PYTHON_LIBRARY)
96+
endif(APPLE)
9397
endif(PYTHONINTERP_FOUND)
9498

9599
if(PYTHONLIBRARY_FOUND)
@@ -103,6 +107,7 @@ else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "
103107
message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
104108
message(STATUS "Found Python version: ${PYTHON_LONG_VERSION}")
105109
message(STATUS "Found Python library: ${PYTHON_LIBRARY}")
110+
message(STATUS "Found Python site-pacakges: ${PYTHON_SITE_PACKAGES_DIR}")
106111
endif(NOT PYTHONLIBRARY_FIND_QUIETLY)
107112
else(PYTHONLIBRARY_FOUND)
108113
if(PYTHONLIBRARY_FIND_REQUIRED)

cmake/FindQCA.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ else(QCA_INCLUDE_DIR AND QCA_LIBRARY)
3232
)
3333

3434
if(APPLE)
35-
if(QCA_LIBRARY AND QCA_LIBRARY MATCHES "qca(2)?\\.framework")
35+
if(QCA_LIBRARY AND QCA_LIBRARY MATCHES "qca(2)?-qt5\\.framework")
3636
set(QCA_LIBRARY "${QCA_LIBRARY}" CACHE FILEPATH "QCA framework" FORCE)
3737
set(QCA_INCLUDE_DIR "${QCA_LIBRARY}/Headers" CACHE FILEPATH "QCA framework headers" FORCE)
3838
endif()

cmake/QCAMacros.cmake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
function(FIND_QCAOSSL_PLUGIN_CPP PLUGIN_REQUIRED)
1414

1515
# requires Qt and QCA packages to be found
16-
if(QT_INCLUDE_DIR AND QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY
16+
if(QT_INCLUDES AND Qt5Core_LIBRARIES
1717
AND QCA_INCLUDE_DIR AND QCA_LIBRARY
1818
AND NOT CMAKE_CROSSCOMPILING)
1919

@@ -38,12 +38,16 @@ function(FIND_QCAOSSL_PLUGIN_CPP PLUGIN_REQUIRED)
3838
set(TESTCPP "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/qcaossl.cpp")
3939
file(WRITE ${TESTCPP} "${CODE}")
4040

41-
set(QCA_INCLUDE_DIRECTORIES "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDE_DIR};${QT_QTCORE_INCLUDE_DIR};${QCA_INCLUDE_DIR}")
42-
set(QCA_LINK_LIBRARIES "-DLINK_LIBRARIES:STRING=${QT_QTCORE_LIBRARY};${QCA_LIBRARY}")
41+
set(QCA_INCLUDE_DIRECTORIES "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES};${QCA_INCLUDE_DIR}")
42+
get_target_property(_QtCore_path Qt5::Core LOCATION)
43+
set(QCA_LINK_LIBRARIES "-DLINK_LIBRARIES:STRING=${_QtCore_path};${QCA_LIBRARY}")
4344

4445
try_run(RUN_RESULT COMPILE_RESULT
4546
${CMAKE_BINARY_DIR} ${TESTCPP}
46-
CMAKE_FLAGS "${QCA_INCLUDE_DIRECTORIES}" "${QCA_LINK_LIBRARIES}"
47+
CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=11"
48+
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
49+
"${QCA_INCLUDE_DIRECTORIES}"
50+
"${QCA_LINK_LIBRARIES}"
4751
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
4852
)
4953

src/app/qgisapp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include <QShortcut>
5555
#include <QSpinBox>
5656
#include <QSplashScreen>
57-
#ifndef QT_NO_OPENSSL
57+
#ifndef QT_NO_SSL
5858
#include <QSslConfiguration>
5959
#endif
6060
#include <QStatusBar>
@@ -110,7 +110,7 @@
110110
#include "qgsattributedialog.h"
111111
#include "qgsauthmanager.h"
112112
#include "qgsauthguiutils.h"
113-
#ifndef QT_NO_OPENSSL
113+
#ifndef QT_NO_SSL
114114
#include "qgsauthcertutils.h"
115115
#include "qgsauthsslerrorsdialog.h"
116116
#endif
@@ -11523,7 +11523,7 @@ void QgisApp::namSetup()
1152311523
connect( nam, SIGNAL( requestTimedOut( QNetworkReply* ) ),
1152411524
this, SLOT( namRequestTimedOut( QNetworkReply* ) ) );
1152511525

11526-
#ifndef QT_NO_OPENSSL
11526+
#ifndef QT_NO_SSL
1152711527
connect( nam, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
1152811528
this, SLOT( namSslErrors( QNetworkReply *, const QList<QSslError> & ) ) );
1152911529
#endif
@@ -11645,7 +11645,7 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe
1164511645
auth->setPassword( password );
1164611646
}
1164711647

11648-
#ifndef QT_NO_OPENSSL
11648+
#ifndef QT_NO_SSL
1164911649
void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
1165011650
{
1165111651
// stop the timeout timer, or app crashes if the user (or slot) takes longer than

src/app/qgisapp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
674674
//! request credentials for network manager
675675
void namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth );
676676
void namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth );
677-
#ifndef QT_NO_OPENSSL
677+
#ifndef QT_NO_SSL
678678
void namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors );
679679
#endif
680680
void namRequestTimedOut( QNetworkReply *reply );

src/app/qgsidentifyresultsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWeb
7878
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
7979
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
8080
// page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
81+
#ifdef WITH_QTWEBKIT
8182
page()->setForwardUnsupportedContent( true );
83+
#endif
8284
page()->setLinkDelegationPolicy( QWebPage::DontDelegateLinks );
8385
settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true );
8486
settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows, true );

src/auth/identcert/qgsauthidentcertmethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <QDir>
2121
#include <QFile>
2222
#include <QUuid>
23-
#ifndef QT_NO_OPENSSL
23+
#ifndef QT_NO_SSL
2424
#include <QtCrypto>
2525
#include <QSslConfiguration>
2626
#include <QSslError>

src/auth/pkipaths/qgsauthpkipathsmethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <QDir>
2121
#include <QFile>
2222
#include <QUuid>
23-
#ifndef QT_NO_OPENSSL
23+
#ifndef QT_NO_SSL
2424
#include <QtCrypto>
2525
#include <QSslConfiguration>
2626
#include <QSslError>

src/auth/pkipkcs12/qgsauthpkcs12method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <QDir>
2121
#include <QFile>
2222
#include <QUuid>
23-
#ifndef QT_NO_OPENSSL
23+
#ifndef QT_NO_SSL
2424
#include <QtCrypto>
2525
#include <QSslConfiguration>
2626
#include <QSslError>

src/core/auth/qgsauthconfig.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
#include <QFile>
2222
#include <QObject>
23+
#include <QCryptographicHash>
2324
#include <QUrl>
2425

25-
#include "qgsauthcertutils.h"
26-
2726

2827
//////////////////////////////////////////////
2928
// QgsAuthMethodConfig
@@ -156,7 +155,7 @@ bool QgsAuthMethodConfig::uriToResource( const QString &accessurl, QString *reso
156155
}
157156

158157

159-
#ifndef QT_NO_OPENSSL
158+
#ifndef QT_NO_SSL
160159

161160
//////////////////////////////////////////////////////
162161
// QgsPkiBundle
@@ -302,7 +301,7 @@ const QString QgsPkiBundle::certId() const
302301
{
303302
return QString::null;
304303
}
305-
return QgsAuthCertUtils::shaHexForCert( mCert );
304+
return QString( mCert.digest( QCryptographicHash::Sha1 ).toHex() );
306305
}
307306

308307
void QgsPkiBundle::setClientCert( const QSslCertificate &cert )

src/core/auth/qgsauthconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <QHash>
2121
#include <QString>
2222

23-
#ifndef QT_NO_OPENSSL
23+
#ifndef QT_NO_SSL
2424
#include <QSslCertificate>
2525
#include <QSslKey>
2626
#include <QSslError>
@@ -177,7 +177,7 @@ class CORE_EXPORT QgsAuthMethodConfig
177177
typedef QHash<QString, QgsAuthMethodConfig> QgsAuthMethodConfigsMap;
178178

179179

180-
#ifndef QT_NO_OPENSSL
180+
#ifndef QT_NO_SSL
181181

182182
/** \ingroup core
183183
* \brief Storage set for PKI bundle: SSL certificate, key, optional CA cert chain

src/core/auth/qgsauthmanager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include <QtCrypto>
3535

36-
#ifndef QT_NO_OPENSSL
36+
#ifndef QT_NO_SSL
3737
#include <QSslConfiguration>
3838
#endif
3939

@@ -197,7 +197,7 @@ bool QgsAuthManager::init( const QString& pluginPath )
197197

198198
updateConfigAuthMethods();
199199

200-
#ifndef QT_NO_OPENSSL
200+
#ifndef QT_NO_SSL
201201
initSslCaches();
202202
#endif
203203

@@ -258,7 +258,7 @@ bool QgsAuthManager::init( const QString& pluginPath )
258258
return false;
259259
}
260260

261-
#ifndef QT_NO_OPENSSL
261+
#ifndef QT_NO_SSL
262262
initSslCaches();
263263
#endif
264264

@@ -1572,7 +1572,7 @@ bool QgsAuthManager::removeAuthSetting( const QString& key )
15721572
}
15731573

15741574

1575-
#ifndef QT_NO_OPENSSL
1575+
#ifndef QT_NO_SSL
15761576

15771577
////////////////// Certificate calls ///////////////////////
15781578

src/core/auth/qgsauthmanager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <QSqlQuery>
2727
#include <QStringList>
2828

29-
#ifndef QT_NO_OPENSSL
29+
#ifndef QT_NO_SSL
3030
#include <QSslCertificate>
3131
#include <QSslKey>
3232
#include <QtCrypto>
@@ -339,7 +339,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
339339
//! Remove an authentication setting
340340
bool removeAuthSetting( const QString& key );
341341

342-
#ifndef QT_NO_OPENSSL
342+
#ifndef QT_NO_SSL
343343
////////////////// Certificate calls ///////////////////////
344344

345345
//! Initialize various SSL authentication caches
@@ -581,7 +581,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
581581

582582
bool authDbTransactionQuery( QSqlQuery *query ) const;
583583

584-
#ifndef QT_NO_OPENSSL
584+
#ifndef QT_NO_SSL
585585
void insertCaCertInCache( QgsAuthCertUtils::CaCertSource source, const QList<QSslCertificate> &certs );
586586
#endif
587587

@@ -625,7 +625,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
625625
int mScheduledDbEraseRequestCount;
626626
QMutex *mMutex;
627627

628-
#ifndef QT_NO_OPENSSL
628+
#ifndef QT_NO_SSL
629629
// mapping of sha1 digest and cert source and cert
630630
// appending removes duplicates
631631
QMap<QString, QPair<QgsAuthCertUtils::CaCertSource , QSslCertificate> > mCaCertsCache;

0 commit comments

Comments
 (0)