CMakePM: Update the path to lib.exe upon MSVC compiler update

Previously Qt Creator would only update the path to the compiler
(cl.exe) and linker (link.exe) when detecting that the MSVC toolchain
has been updated.

Now take also into consideration the librarian (lib.exe) referenced by
the CMAKE_AR variable.

Fixes: QTCREATORBUG-32165
Change-Id: I37dafa9a5003507b02d9acdfd2231d226a573407
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-12-11 15:48:14 +01:00
parent 0ed5f8c9ce
commit 11df2309fc

View File

@@ -2389,16 +2389,31 @@ void CMakeBuildSystem::updateInitialCMakeExpandableVars()
} }
} }
// Handle MSVC C/C++ compiler update, by udating also the linker, otherwise projects // Handle MSVC C/C++ compiler update, by udating also the linker and librarian,
// will fail to compile by using a linker that doesn't exist // otherwise projects will fail to compile by using a linker (link.exe) and
// a librarian (lib.exe) that do not exit
const FilePath cxxCompiler = config.filePathValueOf("CMAKE_CXX_COMPILER"); const FilePath cxxCompiler = config.filePathValueOf("CMAKE_CXX_COMPILER");
if (!cxxCompiler.isEmpty() && cxxCompiler.fileName() == "cl.exe") { if (!cxxCompiler.isEmpty() && cxxCompiler.fileName() == "cl.exe") {
const FilePath linker = cm.filePathValueOf("CMAKE_LINKER"); const FilePath linker = cm.filePathValueOf("CMAKE_LINKER");
if (!linker.exists()) if (!linker.exists()) {
const QString linkerFileName = linker.fileName() != "CMAKE_LINKER-NOTFOUND"
? linker.fileName()
: "link.exe";
config << CMakeConfigItem( config << CMakeConfigItem(
"CMAKE_LINKER", "CMAKE_LINKER",
CMakeConfigItem::FILEPATH, CMakeConfigItem::FILEPATH,
cxxCompiler.parentDir().pathAppended(linker.fileName()).path().toUtf8()); cxxCompiler.parentDir().pathAppended(linkerFileName).path().toUtf8());
}
const FilePath librarian = cm.filePathValueOf("CMAKE_AR");
if (!librarian.exists()) {
const QString librarianFileName = librarian.fileName() != "CMAKE_AR-NOTFOUND"
? librarian.fileName()
: "lib.exe";
config << CMakeConfigItem(
"CMAKE_AR",
CMakeConfigItem::FILEPATH,
cxxCompiler.parentDir().pathAppended(librarianFileName).path().toUtf8());
}
} }
if (!config.isEmpty()) if (!config.isEmpty())