From 6075904af52e52f955e3ed404ec0d46c064a1717 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 13 May 2024 10:12:58 +0200 Subject: [PATCH] CMake: Fix library build path for MinGW The code that handled the MinGW case of libFoo.a -> libFoo.dll broke the case of libFoo.dll.a -> libFoo.dll that is handled by the code before that. Amends 0d8a542b4f7d8a7b4d27f42ff16d309fba6cbf22 Amends 8713919f31f2aecc7e7c15f1fc9ce7906b8fefa0 Fixes: QTCREATORBUG-30556 Change-Id: I76f60c5e646bce97169b205860babf6a0d3b08b6 Reviewed-by: Cristian Adam --- .../cmakeprojectmanager/fileapidataextractor.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp index f4212a1a486..f1d3cee4ee3 100644 --- a/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp +++ b/src/plugins/cmakeprojectmanager/fileapidataextractor.cpp @@ -308,7 +308,8 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t, std::optional dllName; if (buildDir.osType() == OsTypeWindows && (f.role == "libraries")) { - part = FilePath::fromUserInput(part).fileName(); + const auto partAsFilePath = FilePath::fromUserInput(part); + part = partAsFilePath.fileName(); // Skip object libraries on Windows. This case can happen with static qml plugins if (part.endsWith(".obj") || part.endsWith(".o")) @@ -322,12 +323,15 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t, } // MinGW has libQt6Core.a -> Qt6Core.dll + // but libFoo.dll.a was already handled above const QString mingwPrefix("lib"); - const QString mingwSuffix(".a"); - if (part.startsWith(mingwPrefix) && part.endsWith(mingwSuffix)) - dllName = part.chopped(mingwSuffix.length()) + const QString mingwSuffix("a"); + const QString completeSuffix = partAsFilePath.completeSuffix(); + if (part.startsWith(mingwPrefix) && completeSuffix == mingwSuffix) { + dllName = part.chopped(mingwSuffix.length() + 1/*the '.'*/) .sliced(mingwPrefix.length()) .append(".dll"); + } } if (!tmp.isEmpty() && tmp.isDir()) {