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 0d8a542b4f
Amends 8713919f31

Fixes: QTCREATORBUG-30556
Change-Id: I76f60c5e646bce97169b205860babf6a0d3b08b6
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2024-05-13 10:12:58 +02:00
parent 67e233fefc
commit 6075904af5

View File

@@ -308,7 +308,8 @@ static CMakeBuildTarget toBuildTarget(const TargetDetails &t,
std::optional<QString> 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()) {