From 11df2309fc90f48e5eccd04951f95fb113730f0b Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 11 Dec 2024 15:48:14 +0100 Subject: [PATCH] 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 --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 3547e96ed10..feec96ac8f5 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -2389,16 +2389,31 @@ void CMakeBuildSystem::updateInitialCMakeExpandableVars() } } - // Handle MSVC C/C++ compiler update, by udating also the linker, otherwise projects - // will fail to compile by using a linker that doesn't exist + // Handle MSVC C/C++ compiler update, by udating also the linker and librarian, + // 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"); if (!cxxCompiler.isEmpty() && cxxCompiler.fileName() == "cl.exe") { 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( "CMAKE_LINKER", 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())