From 8fd96d78f0597fddda0d04fef5fc8c7acb3b468e Mon Sep 17 00:00:00 2001
From: Andreas Holzammer <andreas.holzammer@kdab.com>
Date: Mon, 21 Mar 2016 08:42:11 +0100
Subject: [PATCH] qmake/wince: Deploy QPA plugin as well in Visual Studio

Change-Id: Ia936290ddb61a85be18d903b64d4b11c709b0732
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@theqtcompany.com>
---
 qmake/generators/win32/msvc_vcproj.cpp | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 73c9f397e51..6206b2c8f1e 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -1283,6 +1283,7 @@ void VcprojGenerator::initDeploymentTool()
         !(conf.WinRT && project->first("MSVC_VER").toQString() == "14.0")) {
         // FIXME: This code should actually resolve the libraries from all Qt modules.
         ProStringList arg = project->values("QMAKE_LIBS") + project->values("QMAKE_LIBS_PRIVATE");
+        bool qpaPluginDeployed = false;
         for (ProStringList::ConstIterator it = arg.constBegin(); it != arg.constEnd(); ++it) {
             QString dllName = (*it).toQString();
             dllName.replace(QLatin1Char('\\'), QLatin1Char('/'));
@@ -1315,6 +1316,32 @@ void VcprojGenerator::initDeploymentTool()
                         + "|" + QDir::toNativeSeparators(info.absolutePath())
                         + "|" + targetPath
                         + "|0;";
+                if (!qpaPluginDeployed) {
+                    QChar debugInfixChar;
+                    bool foundGuid = false;
+                    if (foundGuid = dllName.contains(QLatin1String("Guid")))
+                        debugInfixChar = QLatin1Char('d');
+
+                    if (foundGuid || dllName.contains(QLatin1String("Gui"))) {
+                        QFileInfo info2;
+                        foreach (const ProString &dllPath, dllPaths) {
+                            QString absoluteDllFilePath = dllPath.toQString();
+                            if (!absoluteDllFilePath.endsWith(QLatin1Char('/')))
+                                absoluteDllFilePath += QLatin1Char('/');
+                            absoluteDllFilePath += QLatin1String("../plugins/platforms/qwindows") + debugInfixChar + QLatin1String(".dll");
+                            info2 = QFileInfo(absoluteDllFilePath);
+                            if (info2.exists())
+                                break;
+                        }
+                        if (info2.exists()) {
+                            conf.deployment.AdditionalFiles += QLatin1String("qwindows") + debugInfixChar + QLatin1String(".dll")
+                                                        + QLatin1Char('|') + QDir::toNativeSeparators(info2.absolutePath())
+                                                        + QLatin1Char('|') + targetPath + QLatin1String("\\platforms")
+                                                        + QLatin1String("|0;");
+                            qpaPluginDeployed = true;
+                        }
+                    }
+                }
             }
         }
     }
-- 
GitLab