diff --git a/src/plugins/mcusupport/mcukitmanager.cpp b/src/plugins/mcusupport/mcukitmanager.cpp index 19917de3bb7..ae5c5f4b153 100644 --- a/src/plugins/mcusupport/mcukitmanager.cpp +++ b/src/plugins/mcusupport/mcukitmanager.cpp @@ -196,12 +196,22 @@ public: EnvironmentItems changes; QStringList pathAdditions; // clazy:exclude=inefficient-qlist-soft - // The Desktop version depends on the Qt shared libs in Qul_DIR/bin. - // If CMake's fileApi is avaialble, we can rely on the "Add library search path to PATH" - // feature of the run configuration. Otherwise, we just prepend the path, here. - if (mcuTarget->toolChainPackage()->isDesktopToolchain() - && !CMakeProjectManager::CMakeToolManager::defaultCMakeTool()->hasFileApi()) - pathAdditions.append((qtForMCUsSdkPackage->path() / "bin").toUserOutput()); + // The Desktop version depends on the Qt shared libs. + // As CMake's fileApi is available, we can rely on the "Add library search path to PATH" + // feature of the run configuration. + // + // Since MinGW support is added from Qul 2.3.0, + // the Qt shared libs for Windows desktop platform have been moved + // from Qul_DIR/bin to Qul_DIR/lib/(msvc|gnu) + // and the QPA plugin has been moved to the same location. + // So Windows host requires to add the path in this case. + if (mcuTarget->toolChainPackage()->isDesktopToolchain() && HostOsInfo::isWindowsHost() + && !McuSupportOptions::isLegacyVersion(mcuTarget->qulVersion())) { + const FilePath libPath = (qtForMCUsSdkPackage->path() / "lib" + / mcuTarget->desktopCompilerId()); + pathAdditions.append(libPath.toUserOutput()); + changes.append({"QT_QPA_PLATFORM_PLUGIN_PATH", libPath.toUserOutput()}); + } auto processPackage = [&pathAdditions](const McuPackagePtr &package) { if (package->isAddToSystemPath()) @@ -261,6 +271,12 @@ public: true); } + if (!McuSupportOptions::isLegacyVersion(mcuTarget->qulVersion()) + && HostOsInfo::isWindowsHost()) { + // From 2.3.0, QUL_COMPILER_NAME needs to be set on Windows + // to select proper cmake files depending on the toolchain for Windows. + configMap.insert("QUL_COMPILER_NAME", mcuTarget->desktopCompilerId().toLatin1()); + } } else { const FilePath cMakeToolchainFile = mcuTarget->toolChainFilePackage()->path(); diff --git a/src/plugins/mcusupport/mcutarget.cpp b/src/plugins/mcusupport/mcutarget.cpp index 4314bdb72ad..2ca6e2596a1 100644 --- a/src/plugins/mcusupport/mcutarget.cpp +++ b/src/plugins/mcusupport/mcutarget.cpp @@ -61,6 +61,26 @@ bool McuTarget::isValid() const }); } +QString McuTarget::desktopCompilerId() const +{ + // MinGW shares CMake configuration with GCC + // and it is distinguished from MSVC by CMake compiler ID. + // This provides the compiler ID to set up a different Qul configuration + // for MSVC and MinGW. + if (m_toolChainPackage) { + switch (m_toolChainPackage->toolchainType()) { + case McuToolChainPackage::ToolChainType::MSVC: + return QLatin1String("msvc"); + case McuToolChainPackage::ToolChainType::GCC: + case McuToolChainPackage::ToolChainType::MinGW: + return QLatin1String("gnu"); + default: + return QLatin1String("unsupported"); + } + } + return QLatin1String("invalid"); +} + void McuTarget::printPackageProblems() const { for (auto package : packages()) { diff --git a/src/plugins/mcusupport/mcutarget.h b/src/plugins/mcusupport/mcutarget.h index d42cf015d73..6dd1cd5fe35 100644 --- a/src/plugins/mcusupport/mcutarget.h +++ b/src/plugins/mcusupport/mcutarget.h @@ -53,6 +53,7 @@ public: OS os() const; int colorDepth() const; bool isValid() const; + QString desktopCompilerId() const; void printPackageProblems() const; private: