From 9622b544ad4186ff0d69a0424ed027a0d960b00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20K=C3=BCmmel?= Date: Wed, 25 Jul 2012 18:57:14 +0200 Subject: add configure options for debug/release OpenSSL msvc cannot use the same library for debug and release builds if openssl libraries are linked statically into the network library. Backported from 952788d64bc30c7aac5f9572533241ab8f48fb63 Change-Id: I8332b8293a27b6f9bd87ca1e6ebc63327589ab78 Reviewed-by: Shane Kearns --- src/network/ssl/ssl.pri | 13 +++++++++++++ tools/configure/configureapp.cpp | 41 ++++++++++++++++++++++++++++++---------- tools/configure/configureapp.h | 2 ++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri index 8b2e2c1..0f4fb67 100644 --- a/src/network/ssl/ssl.pri +++ b/src/network/ssl/ssl.pri @@ -32,5 +32,18 @@ symbian { ssl/qsslsocket_openssl_symbols.cpp # Add optional SSL libs + # Static linking of OpenSSL with msvc: + # - Binaries http://slproweb.com/products/Win32OpenSSL.html + # - also needs -lUser32 -lAdvapi32 -lGdi32 -lCrypt32 + # - libs in \lib\VC\static + # - configure: -openssl -openssl-linked -I \include -L \lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32 -lCrypt32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD" + + CONFIG(debug, debug|release) { + LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG + } else { + LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE + } + LIBS_PRIVATE += $$OPENSSL_LIBS + } diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 55049d3..1a559e9 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1082,6 +1082,10 @@ void Configure::parseCmdLine() qmakeLibs += QString("-l" + configCmdLine.at(i)); } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) { opensslLibs = configCmdLine.at(i); + } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS_DEBUG=")) { + opensslLibsDebug = configCmdLine.at(i); + } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS_RELEASE=")) { + opensslLibsRelease = configCmdLine.at(i); } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) { psqlLibs = configCmdLine.at(i); } else if (configCmdLine.at(i).startsWith("SYBASE=")) { @@ -3032,12 +3036,22 @@ void Configure::generateOutputVars() qmakeVars += QString("INCLUDEPATH += ") + escapeSeparators(qmakeIncludes.join(" ")); if (!opensslLibs.isEmpty()) qmakeVars += opensslLibs; - else if (dictionary[ "OPENSSL" ] == "linked") { - if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("symbian")) - qmakeVars += QString("OPENSSL_LIBS = -llibssl -llibcrypto"); - else - qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32"); + if (dictionary[ "OPENSSL" ] == "linked") { + if (!opensslLibsDebug.isEmpty() || !opensslLibsRelease.isEmpty()) { + if (opensslLibsDebug.isEmpty() || opensslLibsRelease.isEmpty()) { + cout << "Error: either both or none of OPENSSL_LIBS_DEBUG/_RELEASE must be defined." << endl; + exit(1); + } + qmakeVars += opensslLibsDebug; + qmakeVars += opensslLibsRelease; + } else if (opensslLibs.isEmpty()) { + if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("symbian")) { + qmakeVars += QString("OPENSSL_LIBS = -llibssl -llibcrypto"); + } else { + qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32"); + } } + } if (!psqlLibs.isEmpty()) qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1); @@ -3806,11 +3820,18 @@ void Configure::displayConfig() cout << "WARNING: Using static linking will disable the use of plugins." << endl; cout << " Make sure you compile ALL needed modules into the library." << endl; } - if (dictionary[ "OPENSSL" ] == "linked" && opensslLibs.isEmpty()) { - cout << "NOTE: When linking against OpenSSL, you can override the default" << endl; - cout << "library names through OPENSSL_LIBS." << endl; - cout << "For example:" << endl; - cout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl; + if (dictionary[ "OPENSSL" ] == "linked") { + if (!opensslLibsDebug.isEmpty() || !opensslLibsRelease.isEmpty()) { + cout << "Using OpenSSL libraries:" << endl; + cout << " debug : " << opensslLibsDebug << endl; + cout << " release: " << opensslLibsRelease << endl; + cout << " both : " << opensslLibs << endl; + } else if (opensslLibs.isEmpty()) { + cout << "NOTE: When linking against OpenSSL, you can override the default" << endl; + cout << "library names through OPENSSL_LIBS and optionally OPENSSL_LIBS_DEBUG/OPENSSL_LIBS_RELEASE" << endl; + cout << "For example:" << endl; + cout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl; + } } if (dictionary[ "ZLIB_FORCED" ] == "yes") { QString which_zlib = "supplied"; diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index c3838fb..84c4547 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -131,6 +131,8 @@ private: QStringList qmakeIncludes; QStringList qmakeLibs; QString opensslLibs; + QString opensslLibsDebug; + QString opensslLibsRelease; QString psqlLibs; QString sybase; QString sybaseLibs; -- cgit v0.12