From c39d89199e3fb29a556f293e737e7b2d50e923ad Mon Sep 17 00:00:00 2001 From: Kwangsub Kim Date: Mon, 14 Nov 2022 11:51:17 +0100 Subject: [PATCH] McuSupport: Avoid empty string for cmake toolchain vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the first run of Qt Creator after its installation, MSVC toolchain command is set lazily after it's detected, so an empty string can be set to cmake toolchain variable when a Qt for MCUs kit is created automatically. It needs be avoided to keep the cmake variables valid. Even when the command is not updated, it will work correctly with the default variale (%{Compiler:Executable:(C,CXX)}). Task-number: QTCREATORBUG-28457 Change-Id: I5de277831e7f1e696f67724193938d6eef7a12dd Reviewed-by: Sivert Krøvel Reviewed-by: Reviewed-by: Alessandro Portale --- src/plugins/mcusupport/mcukitmanager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/mcusupport/mcukitmanager.cpp b/src/plugins/mcusupport/mcukitmanager.cpp index 1aba15b1b71..75ef1fe7309 100644 --- a/src/plugins/mcusupport/mcukitmanager.cpp +++ b/src/plugins/mcusupport/mcukitmanager.cpp @@ -259,10 +259,13 @@ public: ProjectExplorer::Constants::CXX_LANGUAGE_ID); if (cToolchain && cxxToolchain) { - configMap.insert("CMAKE_CXX_COMPILER", - cxxToolchain->compilerCommand().toString().toLatin1()); - configMap.insert("CMAKE_C_COMPILER", - cToolchain->compilerCommand().toString().toLatin1()); + if (!cxxToolchain->compilerCommand().isEmpty() + && !cToolchain->compilerCommand().isEmpty()) { + configMap.insert("CMAKE_CXX_COMPILER", + cxxToolchain->compilerCommand().toString().toLatin1()); + configMap.insert("CMAKE_C_COMPILER", + cToolchain->compilerCommand().toString().toLatin1()); + } } else { printMessage(Tr::tr("Warning for target %1: invalid toolchain path (%2). " "Update the toolchain in Edit > Preferences > Kits.")