CMakePM: Do not crash with CMake presets and no CMake tool

If no CMake is found, show an error message (reusing an existing
translated string).

Fixes: QTCREATORBUG-30505
Change-Id: I6e3037ee97dfba21791191483fffab769a451125
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-03-13 13:11:23 +01:00
committed by Alessandro Portale
parent 90f66d63fa
commit 52c39d007f

View File

@@ -17,6 +17,7 @@
#include <projectexplorer/kitaspects.h> #include <projectexplorer/kitaspects.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/taskhub.h>
#include <projectexplorer/toolchainmanager.h> #include <projectexplorer/toolchainmanager.h>
#include <qtsupport/qtkitaspect.h> #include <qtsupport/qtkitaspect.h>
@@ -723,8 +724,14 @@ QList<void *> CMakeProjectImporter::examineDirectory(const FilePath &importPath,
if (!configurePreset.cmakeExecutable) { if (!configurePreset.cmakeExecutable) {
const CMakeTool *cmakeTool = CMakeToolManager::defaultCMakeTool(); const CMakeTool *cmakeTool = CMakeToolManager::defaultCMakeTool();
if (cmakeTool) if (cmakeTool) {
configurePreset.cmakeExecutable = cmakeTool->cmakeExecutable().toString(); configurePreset.cmakeExecutable = cmakeTool->cmakeExecutable().toString();
} else {
configurePreset.cmakeExecutable = QString();
TaskHub::addTask(
BuildSystemTask(Task::TaskType::Error, Tr::tr("<No CMake Tool available>")));
TaskHub::requestPopup();
}
} else { } else {
QString cmakeExecutable = configurePreset.cmakeExecutable.value(); QString cmakeExecutable = configurePreset.cmakeExecutable.value();
CMakePresets::Macros::expand(configurePreset, env, projectDirectory(), cmakeExecutable); CMakePresets::Macros::expand(configurePreset, env, projectDirectory(), cmakeExecutable);