From 7a46bbe66739015528696e0ff74359fc95a779f7 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 9 Jan 2024 18:59:33 +0100 Subject: [PATCH] CMakePM: Do not add files to utility targets On multi-config systems CMake is reporting "ALL_BUILD" or "ZERO_CHECK" as targets to add files to. When issued from menu File > Add New ... the selected target is the first target namely "ALL_BUILD", which is a utility target and cannot have source files. Fixes: QTCREATORBUG-30170 Change-Id: I7617978c01f0a2554a3ec7d52ef9baaa16ed7a84 Reviewed-by: Alessandro Portale --- src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index ee2bbcf4a80..9ed58160eaf 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -216,7 +216,8 @@ void CMakeBuildSystem::requestDebugging() bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const { - if (dynamic_cast(context)) + const auto cmakeTarget = dynamic_cast(context); + if (cmakeTarget && cmakeTarget->productType() != ProductType::Other) return action == ProjectAction::AddNewFile || action == ProjectAction::AddExistingFile || action == ProjectAction::AddExistingDirectory || action == ProjectAction::Rename || action == ProjectAction::RemoveFile;