qmake: Rework dll deployment
QT_INSTALL_LIBS is not the right place to check for Qt dlls, as they cannot be found there in a non-developer build. In order to be able to find the dlls and make adding dll locations easier for the user, QMAKE_DLLS_PATHS was added. On Windows, the variable points to Qt's bin directory by default. Task-number: QTBUG-44960 Change-Id: Ie4e5beeaadee798a055599387e842d7c0502c27a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
f8cb4ee310
commit
32849f4997
@ -4,10 +4,8 @@ CONFIG *= thread
|
||||
win32 {
|
||||
contains(QT_CONFIG, shared) {
|
||||
# this variable is read by qmake in qmake/generators/win32/msvc_vcproj.cpp
|
||||
# function VcprojGenerator::initDeploymentTool(), which contains some hardcoded
|
||||
# library names (the ones that were static in Qt 4)
|
||||
# it probably doesn't work anymore and should not be in this file
|
||||
QMAKE_QT_DLL = 1
|
||||
# function VcprojGenerator::initDeploymentTool()
|
||||
QMAKE_DLL_PATHS += $$[QT_INSTALL_BINS/get]
|
||||
}
|
||||
}
|
||||
CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG
|
||||
|
@ -1267,31 +1267,43 @@ void VcprojGenerator::initDeploymentTool()
|
||||
if (targetPath.endsWith("/") || targetPath.endsWith("\\"))
|
||||
targetPath.chop(1);
|
||||
}
|
||||
|
||||
ProStringList dllPaths = project->values("QMAKE_DLL_PATHS");
|
||||
// Only deploy Qt libs for shared build
|
||||
if (!project->values("QMAKE_QT_DLL").isEmpty()) {
|
||||
if (!dllPaths.isEmpty()) {
|
||||
// FIXME: This code should actually resolve the libraries from all Qt modules.
|
||||
const QString &qtdir = project->propertyValue(ProKey("QT_INSTALL_LIBS/get")).toQString();
|
||||
ProStringList arg = project->values("QMAKE_LIBS") + project->values("QMAKE_LIBS_PRIVATE");
|
||||
for (ProStringList::ConstIterator it = arg.constBegin(); it != arg.constEnd(); ++it) {
|
||||
if (it->contains(qtdir)) {
|
||||
QString dllName = (*it).toQString();
|
||||
QString dllName = (*it).toQString();
|
||||
dllName.replace(QLatin1Char('\\'), QLatin1Char('/'));
|
||||
// LIBPATH isn't relevant for deployment
|
||||
if (dllName.startsWith(QLatin1String("/LIBPATH:")))
|
||||
continue;
|
||||
// We want to deploy .dlls not .libs
|
||||
if (dllName.endsWith(QLatin1String(".lib")))
|
||||
dllName.replace(dllName.length() - 3, 3, QLatin1String("dll"));
|
||||
// Use only the file name and check in Qt's install path and LIBPATHs to check for existence
|
||||
dllName.remove(0, dllName.lastIndexOf(QLatin1Char('/')) + 1);
|
||||
QFileInfo info;
|
||||
foreach (const ProString &dllPath, dllPaths) {
|
||||
QString absoluteDllFilePath = dllPath.toQString();
|
||||
if (!absoluteDllFilePath.endsWith(QLatin1Char('/')))
|
||||
absoluteDllFilePath += QLatin1Char('/');
|
||||
absoluteDllFilePath += dllName;
|
||||
info = QFileInfo(absoluteDllFilePath);
|
||||
if (info.exists())
|
||||
break;
|
||||
}
|
||||
|
||||
if (dllName.contains(QLatin1String("QAxContainer"))
|
||||
|| dllName.contains(QLatin1String("qtmain"))
|
||||
|| dllName.contains(QLatin1String("QtUiTools")))
|
||||
continue;
|
||||
dllName.replace(QLatin1String(".lib") , QLatin1String(".dll"));
|
||||
QFileInfo info(dllName);
|
||||
if (conf.WinRT) {
|
||||
QString absoluteFilePath(QDir::toNativeSeparators(info.absoluteFilePath()));
|
||||
vcProject.DeploymentFiles.addFile(absoluteFilePath);
|
||||
} else {
|
||||
conf.deployment.AdditionalFiles += info.fileName()
|
||||
+ "|" + QDir::toNativeSeparators(info.absolutePath())
|
||||
+ "|" + targetPath
|
||||
+ "|0;";
|
||||
}
|
||||
if (!info.exists())
|
||||
continue;
|
||||
if (conf.WinRT) {
|
||||
QString absoluteFilePath(QDir::toNativeSeparators(info.absoluteFilePath()));
|
||||
vcProject.DeploymentFiles.addFile(absoluteFilePath);
|
||||
} else {
|
||||
conf.deployment.AdditionalFiles += info.fileName()
|
||||
+ "|" + QDir::toNativeSeparators(info.absolutePath())
|
||||
+ "|" + targetPath
|
||||
+ "|0;";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user