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 <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-06-27 16:46:35 +02:00
parent e2be8f9d16
commit af7382fee8

View File

@@ -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);
}