From 32849f4997e13f540a6c99c9a644239e19839d73 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 16 Mar 2015 14:15:27 +0100 Subject: 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 --- qmake/generators/win32/msvc_vcproj.cpp | 52 +++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 4822bcf22a..3222030018 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -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;"; } } } -- cgit v1.2.3