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.

Change-Id: Ic27ede2d9531b94aff4c50c1699947ce72caf286
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
Peter Kümmel 2012-07-26 17:16:29 +02:00 committed by Qt by Nokia
parent 9a8d74de0a
commit 952788d64b
3 changed files with 42 additions and 8 deletions

View File

@ -27,7 +27,18 @@ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
ssl/qsslcertificateextension.cpp ssl/qsslcertificateextension.cpp
# Add optional SSL libs # Add optional SSL libs
LIBS_PRIVATE += $$OPENSSL_LIBS # Static linking of OpenSSL with msvc:
# - Binaries http://slproweb.com/products/Win32OpenSSL.html
# - also needs -lUser32 -lAdvapi32 -lGdi32 -lCrypt32
# - libs in <OPENSSL_DIR>\lib\VC\static
# - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" 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
windows:LIBS += -lcrypt32 windows:LIBS += -lcrypt32
} }

View File

@ -965,6 +965,10 @@ void Configure::parseCmdLine()
qmakeLibs += QString("-l" + configCmdLine.at(i)); qmakeLibs += QString("-l" + configCmdLine.at(i));
} else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) { } else if (configCmdLine.at(i).startsWith("OPENSSL_LIBS=")) {
opensslLibs = configCmdLine.at(i); 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=")) { } else if (configCmdLine.at(i).startsWith("PSQL_LIBS=")) {
psqlLibs = configCmdLine.at(i); psqlLibs = configCmdLine.at(i);
} else if (configCmdLine.at(i).startsWith("SYBASE=")) { } else if (configCmdLine.at(i).startsWith("SYBASE=")) {
@ -2608,8 +2612,18 @@ void Configure::generateOutputVars()
qmakeVars += QString("INCLUDEPATH += ") + formatPaths(qmakeIncludes); qmakeVars += QString("INCLUDEPATH += ") + formatPaths(qmakeIncludes);
if (!opensslLibs.isEmpty()) if (!opensslLibs.isEmpty())
qmakeVars += opensslLibs; qmakeVars += opensslLibs;
else if (dictionary[ "OPENSSL" ] == "linked") if (dictionary[ "OPENSSL" ] == "linked") {
qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32"); 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()) {
qmakeVars += QString("OPENSSL_LIBS = -lssleay32 -llibeay32");
}
}
if (!psqlLibs.isEmpty()) if (!psqlLibs.isEmpty())
qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1); qmakeVars += QString("QT_LFLAGS_PSQL=") + psqlLibs.section("=", 1);
@ -3402,11 +3416,18 @@ void Configure::displayConfig()
sout << "WARNING: Using static linking will disable the use of plugins." << endl; sout << "WARNING: Using static linking will disable the use of plugins." << endl;
sout << " Make sure you compile ALL needed modules into the library." << endl; sout << " Make sure you compile ALL needed modules into the library." << endl;
} }
if (dictionary[ "OPENSSL" ] == "linked" && opensslLibs.isEmpty()) { if (dictionary[ "OPENSSL" ] == "linked") {
sout << "NOTE: When linking against OpenSSL, you can override the default" << endl; if (!opensslLibsDebug.isEmpty() || !opensslLibsRelease.isEmpty()) {
sout << "library names through OPENSSL_LIBS." << endl; sout << "Using OpenSSL libraries:" << endl;
sout << "For example:" << endl; sout << " debug : " << opensslLibsDebug << endl;
sout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl; sout << " release: " << opensslLibsRelease << endl;
sout << " both : " << opensslLibs << endl;
} else if (opensslLibs.isEmpty()) {
sout << "NOTE: When linking against OpenSSL, you can override the default" << endl;
sout << "library names through OPENSSL_LIBS and optionally OPENSSL_LIBS_DEBUG/OPENSSL_LIBS_RELEASE" << endl;
sout << "For example:" << endl;
sout << " configure -openssl-linked OPENSSL_LIBS=\"-lssleay32 -llibeay32\"" << endl;
}
} }
if (dictionary[ "ZLIB_FORCED" ] == "yes") { if (dictionary[ "ZLIB_FORCED" ] == "yes") {
QString which_zlib = "supplied"; QString which_zlib = "supplied";

View File

@ -141,6 +141,8 @@ private:
QStringList qmakeIncludes; QStringList qmakeIncludes;
QStringList qmakeLibs; QStringList qmakeLibs;
QString opensslLibs; QString opensslLibs;
QString opensslLibsDebug;
QString opensslLibsRelease;
QString psqlLibs; QString psqlLibs;
QString sybase; QString sybase;
QString sybaseLibs; QString sybaseLibs;