From a8370aaf81ac5ccd9aef71c7a2491e977b3a7a11 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Thu, 25 Jan 2024 17:28:53 +0100 Subject: [PATCH] CMakePM: Allow adding files to OBJECT libraries Amends 7a46bbe66739015528696e0ff74359fc95a779f7 which only used `cmakeTarget->productType() != ProductType::Other` which excludes OBJECT libraries. Now the fix actually includes all targets which are not UtilityType, which was the intention of 7a46bbe66739015528696e0ff74359fc95a779f7 Fixes: QTCREATORBUG-29914 Change-Id: If661828e43d5c566c876546f5527c0b670405e47 Reviewed-by: Alessandro Portale --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index a9856ae7b77..255ec0723a8 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -217,10 +217,17 @@ void CMakeBuildSystem::requestDebugging() bool CMakeBuildSystem::supportsAction(Node *context, ProjectAction action, const Node *node) const { 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; + if (cmakeTarget) { + const auto buildTarget = Utils::findOrDefault(m_buildTargets, + [cmakeTarget](const CMakeBuildTarget &bt) { + return bt.title + == cmakeTarget->buildKey(); + }); + if (buildTarget.targetType != UtilityType) + return action == ProjectAction::AddNewFile || action == ProjectAction::AddExistingFile + || action == ProjectAction::AddExistingDirectory + || action == ProjectAction::Rename || action == ProjectAction::RemoveFile; + } return BuildSystem::supportsAction(context, action, node); }