From d37dc75116aeb55971ab44c84e8f10ed18b8a5aa Mon Sep 17 00:00:00 2001
From: Matt Fischer <matt.fischer@garmin.com>
Date: Mon, 8 Apr 2013 17:07:13 -0500
Subject: [PATCH] Improve support for <MODULE>_PATH options

Several modules, including DBus, MySQL, and OpenSSL have
configure options of the form <MODULE>_PATH, which is used
on Windows (where pkg-config is not present) to specify the
locations of third-party libraries.  These switches had been
implemented by adding extra variables which were referenced
in .pro files, to add the appropriate compiler and linker
switches.  This is undesirable because it means there are
two independent paths for adding the switches to the build,
which can get out of sync with each other, and indeed this
had happened for some of the DBus tools.

To remedy the situation, all three of the switches were
reworked so that they added values directly to the principal
variables that are used in the project files.  This reduces
maintenance, by ensuring that the pkg-config and non-pkg-config
paths appear the same to the rest of the build system.

Change-Id: Iae342f1d14b79fbcfef9fe38aadc803ad3141799
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
---
 src/dbus/dbus.pro                    |  4 +---
 src/network/ssl/ssl.pri              |  6 +-----
 src/sql/drivers/mysql/qsql_mysql.pri |  9 ++-------
 tools/configure/configureapp.cpp     | 24 +++++++++++++++---------
 4 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index 2e4119ba930..c5afe8c4d26 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -3,9 +3,7 @@ QT = core-private
 CONFIG += link_pkgconfig
 MODULE_CONFIG = dbusadaptors dbusinterfaces
 
-!isEmpty(DBUS_PATH) {
-    INCLUDEPATH += $$DBUS_PATH/include
-    QMAKE_LIBDIR += $$DBUS_PATH/lib
+!contains(QT_LIBS_DBUS, .*dbus-1.*) {
     win32:CONFIG(debug, debug|release):QT_LIBS_DBUS += -ldbus-1d
     else:QT_LIBS_DBUS += -ldbus-1
 }
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index f5afb437596..1d8c8e1ab71 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -41,11 +41,7 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
         LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE
     }
 
+    QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS
     LIBS_PRIVATE += $$OPENSSL_LIBS
     windows:LIBS += -lcrypt32
-
-    !isEmpty(OPENSSL_PATH) {
-        INCLUDEPATH += $$OPENSSL_PATH/include
-        QMAKE_LIBDIR += $$OPENSSL_PATH/lib
-    }
 }
diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri
index 50f49ca5489..3cfb6144a1d 100644
--- a/src/sql/drivers/mysql/qsql_mysql.pri
+++ b/src/sql/drivers/mysql/qsql_mysql.pri
@@ -1,10 +1,8 @@
 HEADERS += $$PWD/qsql_mysql_p.h
 SOURCES += $$PWD/qsql_mysql.cpp
 
-!isEmpty(MYSQL_PATH) {
-    INCLUDEPATH += $$MYSQL_PATH/include
-    QMAKE_LIBDIR += $$MYSQL_PATH/lib
-}
+QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
+LIBS += $$QT_LFLAGS_MYSQL
 
 unix {
     isEmpty(QT_LFLAGS_MYSQL) {
@@ -12,9 +10,6 @@ unix {
             use_libmysqlclient_r:LIBS += -lmysqlclient_r
             else:LIBS += -lmysqlclient
         }
-    } else {
-        LIBS += $$QT_LFLAGS_MYSQL
-        QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
     }
 } else {
     !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS += -llibmysql
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index fb8f8b8b717..fa8456e4477 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -988,7 +988,7 @@ void Configure::parseCmdLine()
         } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS_RELEASE=")) {
             opensslLibsRelease = configCmdLine.at(i);
         } else if (configCmdLine.at(i).startsWith("OPENSSL_PATH=")) {
-            opensslPath = QDir::fromNativeSeparators(configCmdLine.at(i));
+            opensslPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
         } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) {
             psqlLibs = configCmdLine.at(i);
         } else if (configCmdLine.at(i).startsWith("SYBASE=")) {
@@ -996,9 +996,9 @@ void Configure::parseCmdLine()
         } else if (configCmdLine.at(i).startsWith("SYBASE_LIBS=")) {
             sybaseLibs = configCmdLine.at(i);
         } else if (configCmdLine.at(i).startsWith("DBUS_PATH=")) {
-            dbusPath = QDir::fromNativeSeparators(configCmdLine.at(i));
+            dbusPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
         } else if (configCmdLine.at(i).startsWith("MYSQL_PATH=")) {
-            mysqlPath = QDir::fromNativeSeparators(configCmdLine.at(i));
+            mysqlPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1));
         } else if (configCmdLine.at(i).startsWith("ZLIB_LIBS=")) {
             zlibLibs = QDir::fromNativeSeparators(configCmdLine.at(i));
         }
@@ -2811,13 +2811,19 @@ void Configure::generateOutputVars()
         } else if (opensslLibs.isEmpty()) {
             qmakeVars += QString("OPENSSL_LIBS    = -lssleay32 -llibeay32");
         }
-        if (!opensslPath.isEmpty())
-            qmakeVars += opensslPath;
+        if (!opensslPath.isEmpty()) {
+            qmakeVars += QString("OPENSSL_CFLAGS += -I%1/include").arg(opensslPath);
+            qmakeVars += QString("OPENSSL_LIBS += -L%1/lib").arg(opensslPath);
+        }
+    }
+    if (dictionary[ "DBUS" ] != "no" && !dbusPath.isEmpty()) {
+        qmakeVars += QString("QT_CFLAGS_DBUS = -I%1/include").arg(dbusPath);
+        qmakeVars += QString("QT_LIBS_DBUS = -L%1/lib").arg(dbusPath);
+    }
+    if (dictionary[ "SQL_MYSQL" ] != "no" && !mysqlPath.isEmpty()) {
+        qmakeVars += QString("QT_CFLAGS_MYSQL = -I%1/include").arg(mysqlPath);
+        qmakeVars += QString("QT_LFLAGS_MYSQL = -L%1/lib").arg(mysqlPath);
     }
-    if (dictionary[ "DBUS" ] != "no" && !dbusPath.isEmpty())
-        qmakeVars += dbusPath;
-    if (dictionary[ "SQL_MYSQL" ] != "no" && !mysqlPath.isEmpty())
-        qmakeVars += mysqlPath;
     if (!psqlLibs.isEmpty())
         qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
     if (!zlibLibs.isEmpty())
-- 
GitLab