From 52c39d007f75fdb34bb672ecc2216cabd9e95bb3 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 13 Mar 2024 13:11:23 +0100 Subject: [PATCH] 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 --- src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp index 52ed82f8d77..d16b35f1ef0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectimporter.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -723,8 +724,14 @@ QList CMakeProjectImporter::examineDirectory(const FilePath &importPath, if (!configurePreset.cmakeExecutable) { const CMakeTool *cmakeTool = CMakeToolManager::defaultCMakeTool(); - if (cmakeTool) + if (cmakeTool) { configurePreset.cmakeExecutable = cmakeTool->cmakeExecutable().toString(); + } else { + configurePreset.cmakeExecutable = QString(); + TaskHub::addTask( + BuildSystemTask(Task::TaskType::Error, Tr::tr(""))); + TaskHub::requestPopup(); + } } else { QString cmakeExecutable = configurePreset.cmakeExecutable.value(); CMakePresets::Macros::expand(configurePreset, env, projectDirectory(), cmakeExecutable);