From af7382fee86ec673e3789283ae440e0226f20bd5 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 27 Jun 2024 16:46:35 +0200 Subject: [PATCH] CMakePM: Fix compiling projects upon MSVC Compiler/Linker update Visual Studio is getting a fair number of updates. This involves also an update of the Visual C++ toolchain. This implies changing directory paths from "MSVC/14.39.33519" to "MSVC/ 14.40.33807". The linker "link.exe" is also stored in the same directory as the compiler "cl.exe". This commit makes sure that the linker also gets updated, not just the compiler. Change-Id: If8cd6e716604bc948ec8990921a14425ebcc7c30 Reviewed-by: Alessandro Portale --- src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index c396bde59a1..8c4617144d4 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -2323,6 +2323,18 @@ 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 + 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()) + config << CMakeConfigItem( + "CMAKE_LINKER", + CMakeConfigItem::FILEPATH, + cxxCompiler.parentDir().pathAppended(linker.fileName()).path().toUtf8()); + } + if (!config.isEmpty()) emit configurationChanged(config); }