From 8f50c6cce47eaae781de54eabb0dbff3cfc8b451 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 2 Sep 2008 02:09:58 +0200 Subject: [PATCH] Explicitly provide MOC_DEFINES, use HAVE_SSL instead of QT_NO_OPENSSL. Should fix MacOSX compilation issues This removes the automated DEFINITIONS recognition for MOC (which was not cross-platform apparently); instead, we now explicitly set MOC_DEFINES for things where it matters, such as -DHAVE_DBUS and -DHAVE_SSL. --- CMakeLists.txt | 3 ++- cmake/modules/FindQt4.cmake | 26 ++++---------------------- src/client/clientsyncer.cpp | 8 ++++---- src/client/clientsyncer.h | 28 ++++++++++++++-------------- src/core/core.cpp | 6 +++--- src/core/core.h | 14 +++++++------- src/core/networkconnection.cpp | 8 ++++---- src/core/networkconnection.h | 6 +++--- src/core/sslserver.cpp | 6 +++--- src/core/sslserver.h | 12 +++++------- src/qtui/coreconnectdlg.cpp | 4 ++-- 11 files changed, 51 insertions(+), 70 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af3f3a39..3601b0fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,6 @@ if(HAVE_EXECINFO) add_definitions(-DHAVE_EXECINFO) endif(HAVE_EXECINFO) - # Select a Qt installation here, if you don't want to use system Qt if(QT) # FindQt4 will look for the qmake binary in $PATH, so we just prepend the Qt dir @@ -138,6 +137,7 @@ if(OPENSSL_FOUND) message(STATUS "Found OpenSSL support in Qt") add_definitions(-DHAVE_SSL) set(HAVE_SSL true) + set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_SSL) else(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL") message(STATUS "No OpenSSL support found in Qt, disabling") endif(NOT QT_DEFINITIONS MATCHES "QT_NO_OPENSSL") @@ -152,6 +152,7 @@ if(WITH_DBUS) add_definitions(-DHAVE_DBUS) set(LINK_DBUS DBUS) set(HAVE_DBUS true) + set(MOC_DEFINES ${MOC_DEFINES} -DHAVE_DBUS) else(QT_QTDBUS_FOUND) message(STATUS "QtDBus not found, disabling D-Bus support") endif(QT_QTDBUS_FOUND) diff --git a/cmake/modules/FindQt4.cmake b/cmake/modules/FindQt4.cmake index fd9a4f24..170e04b7 100644 --- a/cmake/modules/FindQt4.cmake +++ b/cmake/modules/FindQt4.cmake @@ -1142,28 +1142,10 @@ IF (QT4_QMAKE_FOUND) ENDMACRO(QT4_GET_MOC_INC_DIRS) - # Added by Sput to provide definitions to moc calls - MACRO (QT4_GET_MOC_DEFINES _moc_DEFINES) - SET(${_moc_DEFINES}) - IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6) - GET_DIRECTORY_PROPERTY(_defines DEFINITIONS) - SEPARATE_ARGUMENTS(_defines) - FOREACH(_current ${_defines}) - SET(${_moc_DEFINES} ${${_moc_DEFINES}} ${_current}) - ENDFOREACH(_current ${_defines}) - ELSE(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6) - GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) - FOREACH(_current ${_defines}) - SET(${_moc_DEFINES} ${${_moc_DEFINES}} -D${_current}) - ENDFOREACH(_current ${_defines}) - ENDIF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6) - - ENDMACRO(QT4_GET_MOC_DEFINES) - MACRO (QT4_GENERATE_MOC infile outfile ) # get include dirs # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed... - QT4_GET_MOC_DEFINES(moc_defines) + # QT4_GET_MOC_DEFINES(moc_defines) # Now supplied via ${MOC_DEFINES} GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE) @@ -1179,7 +1161,7 @@ IF (QT4_QMAKE_FOUND) ELSE (MSVC_IDE) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} ${moc_defines} -o ${outfile} ${abs_infile} + ARGS ${moc_includes} ${MOC_DEFINES} -o ${outfile} ${abs_infile} DEPENDS ${abs_infile}) ENDIF (MSVC_IDE) @@ -1194,7 +1176,7 @@ IF (QT4_QMAKE_FOUND) MACRO (QT4_WRAP_CPP outfiles ) # get include dirs # QT4_GET_MOC_INC_DIRS(moc_includes) # Not needed - QT4_GET_MOC_DEFINES(moc_defines) + # QT4_GET_MOC_DEFINES(moc_defines) # Now supplied via ${MOC_DEFINES} QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN}) FOREACH (it ${moc_files}) @@ -1204,7 +1186,7 @@ IF (QT4_QMAKE_FOUND) SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/moc_${outfile}.cxx) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} ${moc_defines} ${moc_options} -o ${outfile} ${it} + ARGS ${moc_includes} ${MOC_DEFINES} ${moc_options} -o ${outfile} ${it} DEPENDS ${it}) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH(it) diff --git a/src/client/clientsyncer.cpp b/src/client/clientsyncer.cpp index 79d8c91f..b65ba566 100644 --- a/src/client/clientsyncer.cpp +++ b/src/client/clientsyncer.cpp @@ -124,7 +124,7 @@ void ClientSyncer::connectToCore(const QVariantMap &conn) { //emit coreConnectionMsg(tr("Connecting...")); Q_ASSERT(!socket); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL QSslSocket *sock = new QSslSocket(Client::instance()); #else if(conn["useSsl"].toBool()) { @@ -196,7 +196,7 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { } emit connectionMsg(msg["CoreInfo"].toString()); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL if(coreConnectionInfo["useSsl"].toBool()) { if(msg["SupportSsl"].toBool()) { QSslSocket *sslSocket = qobject_cast(socket); @@ -219,7 +219,7 @@ void ClientSyncer::clientInitAck(const QVariantMap &msg) { socket->setProperty("UseCompression", true); } #endif - + if(!msg["Configured"].toBool()) { // start wizard emit startCoreSetup(msg["StorageBackends"].toList()); @@ -299,7 +299,7 @@ void ClientSyncer::checkSyncState() { } } -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void ClientSyncer::sslErrors(const QList &errors) { qDebug() << "SSL Errors:"; foreach(QSslError err, errors) diff --git a/src/client/clientsyncer.h b/src/client/clientsyncer.h index 8f370483..b77b234b 100644 --- a/src/client/clientsyncer.h +++ b/src/client/clientsyncer.h @@ -25,10 +25,10 @@ #include #include -#ifndef QT_NO_OPENSSL -#include +#ifdef HAVE_SSL +# include #else -#include +# include #endif class IrcUser; @@ -40,7 +40,7 @@ class ClientSyncer : public QObject { public: ClientSyncer(QObject *parent = 0); ~ClientSyncer(); - + signals: void recvPartialItem(quint32 avail, quint32 size); void connectionError(const QString &errorMsg); @@ -49,7 +49,7 @@ signals: void networksProgress(quint32 part, quint32 total); void socketStateChanged(QAbstractSocket::SocketState); void socketDisconnected(); - + void startLogin(); void loginFailed(const QString &error); void loginSuccess(); @@ -57,14 +57,14 @@ signals: void startCoreSetup(const QVariantList &); void coreSetupSuccess(); void coreSetupFailed(const QString &error); - + void encrypted(bool); - + public slots: void connectToCore(const QVariantMap &); void loginToCore(const QString &user, const QString &passwd); void disconnectFromCore(); - + private slots: void coreSocketError(QAbstractSocket::SocketError); void coreHasData(); @@ -72,24 +72,24 @@ private slots: void coreSocketDisconnected(); void clientInitAck(const QVariantMap &msg); - + // for sync progress void networkInitDone(); void checkSyncState(); - + void syncToCore(const QVariantMap &sessionState); void sessionStateReceived(const QVariantMap &state); - + void doCoreSetup(const QVariant &setupData); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void sslErrors(const QList &errors); #endif - + private: QPointer socket; quint32 blockSize; QVariantMap coreConnectionInfo; - + QSet netsToSync; int numNetsToSync; }; diff --git a/src/core/core.cpp b/src/core/core.cpp index dd33cec5..4a5a64ee 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -433,7 +433,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate) .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime().toString(Qt::TextDate)); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL SslServer *sslServer = qobject_cast(&server); QSslSocket *sslSocket = qobject_cast(socket); bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->certIsValid(); @@ -472,7 +472,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { reply["MsgType"] = "ClientInitAck"; SignalProxy::writeDataToDevice(socket, reply); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL // after we told the client that we are ssl capable we switch to ssl mode if(supportSsl && msg["UseSsl"].toBool()) { quDebug() << qPrintable(tr("Starting TLS for Client:")) << qPrintable(socket->peerAddress().toString()); @@ -597,7 +597,7 @@ SessionThread *Core::createSession(UserId uid, bool restore) { return sess; } -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void Core::sslErrors(const QList &errors) { Q_UNUSED(errors); QSslSocket *socket = qobject_cast(sender()); diff --git a/src/core/core.h b/src/core/core.h index 11918957..fdcc2911 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -27,12 +27,12 @@ #include #include -#ifndef QT_NO_OPENSSL -#include -#include "sslserver.h" +#ifdef HAVE_SSL +# include +# include "sslserver.h" #else -#include -#include +# include +# include #endif #include "bufferinfo.h" @@ -303,7 +303,7 @@ class Core : public QObject { bool initStorage(QVariantMap dbSettings, bool setup = false); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void sslErrors(const QList &errors); #endif void socketError(QAbstractSocket::SocketError); @@ -327,7 +327,7 @@ class Core : public QObject { Storage *storage; QTimer _storageSyncTimer; -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL SslServer server; #else QTcpServer server; diff --git a/src/core/networkconnection.cpp b/src/core/networkconnection.cpp index 69ce0369..5815a910 100644 --- a/src/core/networkconnection.cpp +++ b/src/core/networkconnection.cpp @@ -89,7 +89,7 @@ NetworkConnection::NetworkConnection(Network *network, CoreSession *session) connect(network, SIGNAL(autoReconnectIntervalSet(quint32)), this, SLOT(autoReconnectSettingsChanged())); connect(network, SIGNAL(autoReconnectRetriesSet(quint16)), this, SLOT(autoReconnectSettingsChanged())); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL connect(&socket, SIGNAL(encrypted()), this, SLOT(socketEncrypted())); connect(&socket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); #endif @@ -291,7 +291,7 @@ void NetworkConnection::socketError(QAbstractSocket::SocketError) { //exit(1); } -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void NetworkConnection::sslErrors(const QList &sslErrors) { Q_UNUSED(sslErrors) @@ -315,10 +315,10 @@ void NetworkConnection::socketEncrypted() { socketInitialized(); } -#endif // QT_NO_OPENSSL +#endif // HAVE_SSL void NetworkConnection::socketConnected() { -#ifdef QT_NO_OPENSSL +#ifndef HAVE_SSL socketInitialized(); return; #else diff --git a/src/core/networkconnection.h b/src/core/networkconnection.h index 111ffe76..0d8d837a 100644 --- a/src/core/networkconnection.h +++ b/src/core/networkconnection.h @@ -26,7 +26,7 @@ #include #include -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL # include # include #else @@ -143,7 +143,7 @@ private slots: void startAutoWhoCycle(); void nickChanged(const QString &newNick, const QString &oldNick); // this signal is inteded to rename query buffers in the storage backend -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL void socketEncrypted(); void sslErrors(const QList &errors); #endif @@ -151,7 +151,7 @@ private slots: void fillBucketAndProcessQueue(); private: -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL QSslSocket socket; #else QTcpSocket socket; diff --git a/src/core/sslserver.cpp b/src/core/sslserver.cpp index 307c46ba..c94859ed 100644 --- a/src/core/sslserver.cpp +++ b/src/core/sslserver.cpp @@ -20,7 +20,7 @@ #include "sslserver.h" -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL # include #endif @@ -30,7 +30,7 @@ #include "logger.h" #include "util.h" -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL SslServer::SslServer(QObject *parent) : QTcpServer(parent) @@ -73,4 +73,4 @@ void SslServer::incomingConnection(int socketDescriptor) { } } -#endif // QT_NO_OPENSSL +#endif // HAVE_SSL diff --git a/src/core/sslserver.h b/src/core/sslserver.h index fdbecbf2..1a02cff9 100644 --- a/src/core/sslserver.h +++ b/src/core/sslserver.h @@ -21,14 +21,12 @@ #ifndef SSLSERVER_H #define SSLSERVER_H -#ifndef QT_NO_OPENSSL -# include -# include +#ifdef HAVE_SSL + +#include +#include #include #include -#endif - -#ifndef QT_NO_OPENSSL class SslServer : public QTcpServer { Q_OBJECT @@ -53,6 +51,6 @@ private: bool _certIsValid; }; -#endif //QT_NO_OPENSSL +#endif //HAVE_SSL #endif //SSLSERVER_H diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp index ad7e68af..dfbf9dba 100644 --- a/src/qtui/coreconnectdlg.cpp +++ b/src/qtui/coreconnectdlg.cpp @@ -443,7 +443,7 @@ CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, co ui.port->setValue(acct["Port"].toUInt()); ui.useInternal->setChecked(acct["UseInternal"].toBool()); ui.accountName->setText(acct["AccountName"].toString()); -#ifndef QT_NO_OPENSSL +#ifdef HAVE_SSL ui.useSsl->setChecked(acct["useSsl"].toBool()); #else ui.useSsl->setChecked(false); @@ -457,7 +457,7 @@ CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, co ui.proxyPassword->setText(acct["proxyPassword"].toString()); } else { setWindowTitle(tr("Add Core Account")); -#ifdef QT_NO_OPENSSL +#ifndef HAVE_SSL ui.useSsl->setChecked(false); ui.useSsl->setEnabled(false); #endif -- 2.20.1