Merge pull request #3790 from dakcarto/qt5py3-mac-fixes

Qt5py3 Mac fixes
This commit is contained in:
Larry Shaffer 2016-11-22 21:29:38 -07:00 committed by GitHub
commit d712b49a74
21 changed files with 116 additions and 65 deletions

View File

@ -105,10 +105,6 @@ IF (WITH_BINDINGS)
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.")
# keep casual users from updating their source tree via WITH_QSCIAPI
MARK_AS_ADVANCED (WITH_QSCIAPI)
# path to custom Python framework on Mac
IF (APPLE)
SET (PYTHON_CUSTOM_FRAMEWORK "" CACHE PATH "Path to custom Python.framework on Mac. (should not have to specify other Python options)")
ENDIF (APPLE)
ENDIF (WITH_BINDINGS)
#BUILD WITH QtMobility by default on android only. Other platform can force it

View File

@ -0,0 +1,42 @@
# Macros/functions for debugging CMake
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016, Larry Shaffer, <lshaffer (at) boundlessgeo (dot) com>>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Dump current CMake variables to file
#
# Usage:
# INCLUDE(CMakeDebugMacros)
# DUMP_CMAKE_VARS() or DUMP_CMAKE_VARS("regex")
#
# regex: optional ARGV0 regular expression for filtering output variable names
#
# Outputs the result relative to the current CMake file being processed and
# writes to a file with name "<file-basename>_cmake-vars.txt" to the current
# build (binary) directory
#
function(DUMP_CMAKE_VARS)
get_filename_component(_basename ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
set(_out "${CMAKE_CURRENT_BINARY_DIR}/${_basename}_cmake-vars.txt")
set(_cmake_vars "")
get_cmake_property(_varNames VARIABLES)
foreach(_varName ${_varNames})
if(ARGV0)
string(REGEX MATCH "${ARGV0}" _match "${_varName}")
if(_match)
set(_cmake_vars "${_cmake_vars}\n\n${_varName}=${${_varName}}")
endif()
else()
set(_cmake_vars "${_cmake_vars}\n\n${_varName}=${${_varName}}")
endif()
endforeach()
message(STATUS "Dumping current CMake variables to ...\n ${_out}")
file(WRITE "${_out}" "${_cmake_vars}")
endfunction(DUMP_CMAKE_VARS)

View File

@ -37,6 +37,9 @@ ELSE(EXISTS PYQT5_VERSION)
STRING(REGEX REPLACE ".*\npyqt_version_num:([^\n]+).*$" "\\1" PYQT5_VERSION_NUM ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_mod_dir:([^\n]+).*$" "\\1" PYQT5_MOD_DIR ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_sip_dir:([^\n]+).*$" "\\1" PYQT5_SIP_DIR ${pyqt_config})
IF(EXISTS ${PYQT5_SIP_DIR}/Qt5)
SET(PYQT5_SIP_DIR ${PYQT5_SIP_DIR}/Qt5)
ENDIF(EXISTS ${PYQT5_SIP_DIR}/Qt5)
STRING(REGEX REPLACE ".*\npyqt_sip_flags:([^\n]+).*$" "\\1" PYQT5_SIP_FLAGS ${pyqt_config})
STRING(REGEX REPLACE ".*\npyqt_bin_dir:([^\n]+).*$" "\\1" PYQT5_BIN_DIR ${pyqt_config})

View File

@ -31,19 +31,6 @@ if(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "${
set(PYTHONLIBRARY_FOUND TRUE)
else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "${PYTHON_SITE_PACKAGES_DIR}")
set(_custom_python_fw FALSE)
if(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
if("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
STRING(REGEX REPLACE "(.*Python\\.framework).*$" "\\1" _python_fw "${PYTHON_CUSTOM_FRAMEWORK}")
set(PYTHON_EXECUTABLE "${_python_fw}/Versions/Current/bin/python")
set(PYTHON_INCLUDE_PATH "${_python_fw}/Versions/Current/Headers")
set(PYTHON_LIBRARY "${_python_fw}/Versions/Current/Python")
if(EXISTS "${PYTHON_EXECUTABLE}" AND EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}")
set(_custom_python_fw TRUE)
endif()
endif("${PYTHON_CUSTOM_FRAMEWORK}" MATCHES "Python\\.framework")
endif(APPLE AND PYTHON_CUSTOM_FRAMEWORK)
FIND_PACKAGE(PythonInterp 3)
if(PYTHONINTERP_FOUND)
@ -74,22 +61,39 @@ else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "
endif(python_config)
# adapted from cmake's builtin FindPythonLibs
if(APPLE AND NOT _custom_python_fw)
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(APPLE)
# If a framework has been detected in the include path, make sure
# framework's versioned library (not any .dylib) is used for linking
# NOTE: don't rely upon Python.framework/Versions/Current, since that may be 2.7
if("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
set(PYTHON_LIBRARY "")
set(PYTHON_DEBUG_LIBRARY "")
# get clean path to just framework
STRING(REGEX REPLACE "^(.*/Python\\.framework).*$" "\\1" _py_fw "${PYTHON_INCLUDE_PATH}")
if("${_py_fw}" MATCHES "Cellar/python")
# Appears to be a Homebrew Python install; do specific fix ups
# get Homebrew prefix (may not be /usr/local)
STRING(REGEX REPLACE "^(.+)/Cellar.*$" "\\1" _hb_prefix "${_py_fw}")
# prefer the Homebrew prefix framework over only versioned Python keg
set(_py_fw "${_hb_prefix}/Frameworks/Python.framework")
# prefer the symlinked-to Homebrew site-packages over only versioned Python keg
set(PYTHON_SITE_PACKAGES_DIR "${_hb_prefix}/lib/python${PYTHON_SHORT_VERSION}/site-packages")
endif("${_py_fw}" MATCHES "Cellar/python")
# prefer the Headers subdirectory for includes
if(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers")
set(PYTHON_INCLUDE_PATH "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers" CACHE FILEPATH "Directory holding the python.h include file" FORCE)
endif(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Headers")
endif("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
if(NOT PYTHON_LIBRARY)
set (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
# ensure the versioned framework's library is defined, instead of relying upon -F search paths
if(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python")
set(PYTHON_LIBRARY "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python" CACHE FILEPATH "Python framework library" FORCE)
endif(EXISTS "${_py_fw}/Versions/${PYTHON_SHORT_VERSION}/Python")
endif(NOT PYTHON_LIBRARY)
set(PYTHONLIBRARY_FOUND TRUE)
endif(Python_FRAMEWORKS)
endif(APPLE AND NOT _custom_python_fw)
if(PYTHON_LIBRARY)
set(PYTHONLIBRARY_FOUND TRUE)
endif(PYTHON_LIBRARY)
endif(APPLE)
endif(PYTHONINTERP_FOUND)
if(PYTHONLIBRARY_FOUND)
@ -103,6 +107,7 @@ else(EXISTS "${PYTHON_INCLUDE_PATH}" AND EXISTS "${PYTHON_LIBRARY}" AND EXISTS "
message(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
message(STATUS "Found Python version: ${PYTHON_LONG_VERSION}")
message(STATUS "Found Python library: ${PYTHON_LIBRARY}")
message(STATUS "Found Python site-pacakges: ${PYTHON_SITE_PACKAGES_DIR}")
endif(NOT PYTHONLIBRARY_FIND_QUIETLY)
else(PYTHONLIBRARY_FOUND)
if(PYTHONLIBRARY_FIND_REQUIRED)

View File

@ -32,7 +32,7 @@ else(QCA_INCLUDE_DIR AND QCA_LIBRARY)
)
if(APPLE)
if(QCA_LIBRARY AND QCA_LIBRARY MATCHES "qca(2)?\\.framework")
if(QCA_LIBRARY AND QCA_LIBRARY MATCHES "qca(2)?-qt5\\.framework")
set(QCA_LIBRARY "${QCA_LIBRARY}" CACHE FILEPATH "QCA framework" FORCE)
set(QCA_INCLUDE_DIR "${QCA_LIBRARY}/Headers" CACHE FILEPATH "QCA framework headers" FORCE)
endif()

View File

@ -13,7 +13,7 @@
function(FIND_QCAOSSL_PLUGIN_CPP PLUGIN_REQUIRED)
# requires Qt and QCA packages to be found
if(QT_INCLUDE_DIR AND QT_QTCORE_INCLUDE_DIR AND QT_QTCORE_LIBRARY
if(QT_INCLUDES AND Qt5Core_LIBRARIES
AND QCA_INCLUDE_DIR AND QCA_LIBRARY
AND NOT CMAKE_CROSSCOMPILING)
@ -38,12 +38,16 @@ function(FIND_QCAOSSL_PLUGIN_CPP PLUGIN_REQUIRED)
set(TESTCPP "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/qcaossl.cpp")
file(WRITE ${TESTCPP} "${CODE}")
set(QCA_INCLUDE_DIRECTORIES "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDE_DIR};${QT_QTCORE_INCLUDE_DIR};${QCA_INCLUDE_DIR}")
set(QCA_LINK_LIBRARIES "-DLINK_LIBRARIES:STRING=${QT_QTCORE_LIBRARY};${QCA_LIBRARY}")
set(QCA_INCLUDE_DIRECTORIES "-DINCLUDE_DIRECTORIES:STRING=${QT_INCLUDES};${QCA_INCLUDE_DIR}")
get_target_property(_QtCore_path Qt5::Core LOCATION)
set(QCA_LINK_LIBRARIES "-DLINK_LIBRARIES:STRING=${_QtCore_path};${QCA_LIBRARY}")
try_run(RUN_RESULT COMPILE_RESULT
${CMAKE_BINARY_DIR} ${TESTCPP}
CMAKE_FLAGS "${QCA_INCLUDE_DIRECTORIES}" "${QCA_LINK_LIBRARIES}"
CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=11"
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"${QCA_INCLUDE_DIRECTORIES}"
"${QCA_LINK_LIBRARIES}"
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
)

View File

@ -54,7 +54,7 @@
#include <QShortcut>
#include <QSpinBox>
#include <QSplashScreen>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslConfiguration>
#endif
#include <QStatusBar>
@ -110,7 +110,7 @@
#include "qgsattributedialog.h"
#include "qgsauthmanager.h"
#include "qgsauthguiutils.h"
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include "qgsauthcertutils.h"
#include "qgsauthsslerrorsdialog.h"
#endif
@ -11523,7 +11523,7 @@ void QgisApp::namSetup()
connect( nam, SIGNAL( requestTimedOut( QNetworkReply* ) ),
this, SLOT( namRequestTimedOut( QNetworkReply* ) ) );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
connect( nam, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
this, SLOT( namSslErrors( QNetworkReply *, const QList<QSslError> & ) ) );
#endif
@ -11645,7 +11645,7 @@ void QgisApp::namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthe
auth->setPassword( password );
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
{
// stop the timeout timer, or app crashes if the user (or slot) takes longer than

View File

@ -674,7 +674,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! request credentials for network manager
void namAuthenticationRequired( QNetworkReply *reply, QAuthenticator *auth );
void namProxyAuthenticationRequired( const QNetworkProxy &proxy, QAuthenticator *auth );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors );
#endif
void namRequestTimedOut( QNetworkReply *reply );

View File

@ -78,7 +78,9 @@ QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QgsWeb
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
// page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
#ifdef WITH_QTWEBKIT
page()->setForwardUnsupportedContent( true );
#endif
page()->setLinkDelegationPolicy( QWebPage::DontDelegateLinks );
settings()->setAttribute( QWebSettings::LocalContentCanAccessRemoteUrls, true );
settings()->setAttribute( QWebSettings::JavascriptCanOpenWindows, true );

View File

@ -20,7 +20,7 @@
#include <QDir>
#include <QFile>
#include <QUuid>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QtCrypto>
#include <QSslConfiguration>
#include <QSslError>

View File

@ -20,7 +20,7 @@
#include <QDir>
#include <QFile>
#include <QUuid>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QtCrypto>
#include <QSslConfiguration>
#include <QSslError>

View File

@ -20,7 +20,7 @@
#include <QDir>
#include <QFile>
#include <QUuid>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QtCrypto>
#include <QSslConfiguration>
#include <QSslError>

View File

@ -20,10 +20,9 @@
#include <QFile>
#include <QObject>
#include <QCryptographicHash>
#include <QUrl>
#include "qgsauthcertutils.h"
//////////////////////////////////////////////
// QgsAuthMethodConfig
@ -156,7 +155,7 @@ bool QgsAuthMethodConfig::uriToResource( const QString &accessurl, QString *reso
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
//////////////////////////////////////////////////////
// QgsPkiBundle
@ -302,7 +301,7 @@ const QString QgsPkiBundle::certId() const
{
return QString::null;
}
return QgsAuthCertUtils::shaHexForCert( mCert );
return QString( mCert.digest( QCryptographicHash::Sha1 ).toHex() );
}
void QgsPkiBundle::setClientCert( const QSslCertificate &cert )

View File

@ -20,7 +20,7 @@
#include <QHash>
#include <QString>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslCertificate>
#include <QSslKey>
#include <QSslError>
@ -177,7 +177,7 @@ class CORE_EXPORT QgsAuthMethodConfig
typedef QHash<QString, QgsAuthMethodConfig> QgsAuthMethodConfigsMap;
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
/** \ingroup core
* \brief Storage set for PKI bundle: SSL certificate, key, optional CA cert chain

View File

@ -33,7 +33,7 @@
#include <QtCrypto>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslConfiguration>
#endif
@ -197,7 +197,7 @@ bool QgsAuthManager::init( const QString& pluginPath )
updateConfigAuthMethods();
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
initSslCaches();
#endif
@ -258,7 +258,7 @@ bool QgsAuthManager::init( const QString& pluginPath )
return false;
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
initSslCaches();
#endif
@ -1572,7 +1572,7 @@ bool QgsAuthManager::removeAuthSetting( const QString& key )
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
////////////////// Certificate calls ///////////////////////

View File

@ -26,7 +26,7 @@
#include <QSqlQuery>
#include <QStringList>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslCertificate>
#include <QSslKey>
#include <QtCrypto>
@ -339,7 +339,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
//! Remove an authentication setting
bool removeAuthSetting( const QString& key );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
////////////////// Certificate calls ///////////////////////
//! Initialize various SSL authentication caches
@ -581,7 +581,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
bool authDbTransactionQuery( QSqlQuery *query ) const;
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void insertCaCertInCache( QgsAuthCertUtils::CaCertSource source, const QList<QSslCertificate> &certs );
#endif
@ -625,7 +625,7 @@ class CORE_EXPORT QgsAuthManager : public QObject
int mScheduledDbEraseRequestCount;
QMutex *mMutex;
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
// mapping of sha1 digest and cert source and cert
// appending removes duplicates
QMap<QString, QPair<QgsAuthCertUtils::CaCertSource , QSslCertificate> > mCaCertsCache;

View File

@ -32,7 +32,7 @@
#include <QNetworkReply>
#include <QThreadStorage>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslConfiguration>
#endif
@ -182,7 +182,7 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
userAgent += QStringLiteral( "QGIS/%1" ).arg( Qgis::QGIS_VERSION );
pReq->setRawHeader( "User-Agent", userAgent.toUtf8() );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
bool ishttps = pReq->url().scheme().toLower() == QLatin1String( "https" );
if ( ishttps && !QgsAuthManager::instance()->isDisabled() )
{
@ -305,7 +305,7 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache()
connect( this, SIGNAL( requestTimedOut( QNetworkReply* ) ),
smMainNAM, SIGNAL( requestTimedOut( QNetworkReply* ) ) );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
connect( this, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
smMainNAM, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
Qt::BlockingQueuedConnection );

View File

@ -20,7 +20,7 @@
#include <QFile>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QtCrypto>
#include <QSslCertificate>
#endif

View File

@ -20,7 +20,7 @@
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QMessageBox>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslError>
#endif
@ -64,7 +64,7 @@ void QgsFileDownloader::startDownload()
connect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut );
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors );
#endif
if ( mGuiNotificationsEnabled )
@ -89,7 +89,7 @@ void QgsFileDownloader::onRequestTimedOut()
error( tr( "Network request %1 timed out" ).arg( mUrl.toString() ) );
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
{
Q_UNUSED( reply );

View File

@ -20,7 +20,7 @@
#include <QFile>
#include <QNetworkReply>
#include <QProgressDialog>
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
#include <QSslError>
#endif
@ -87,7 +87,7 @@ class GUI_EXPORT QgsFileDownloader : public QObject
void onRequestTimedOut();
//! Called to start the download
void startDownload();
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
/**
* Called on SSL network Errors

View File

@ -82,7 +82,7 @@ class TestQgsFileDownloader: public QObject
void testInvalidFile();
void testInvalidUrl();
void testBlankUrl();
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void testSslError_data();
void testSslError();
#endif
@ -219,7 +219,7 @@ void TestQgsFileDownloader::testBlankUrl()
QCOMPARE( mErrorMessage, QString( "Network error 301: Protocol \"\" is unknown" ) );
}
#ifndef QT_NO_OPENSSL
#ifndef QT_NO_SSL
void TestQgsFileDownloader::testSslError_data()
{
QTest::addColumn<QString>( "url" );