From c2e657bbf6f6c39f88c21008f045f02e0a4e67db Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 26 Apr 2023 18:29:27 +0200 Subject: [PATCH] CMakePM: Allow file rename / remove for QtQuick projects qt_add_qml_module was not consided when looking for existing project files. This would fail when qt_add_executable and qt_add_qml_module were used with the same target name. Change-Id: Ib7374a3e1213c23aaf12d100a8817a46d57a4303 Reviewed-by: hjk Reviewed-by: --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index 0ea477752ca..805f84f7c24 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -411,15 +411,25 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q }); const std::string target_name = targetName.toStdString(); - auto targetSourcesFunc - = std::find_if(cmakeListFile.Functions.begin(), - cmakeListFile.Functions.end(), - [target_name = targetName.toStdString()](const auto &func) { - return func.LowerCaseName() == "target_sources" - && func.Arguments().front().Value == target_name; - }); + auto targetSourcesFunc = std::find_if(cmakeListFile.Functions.begin(), + cmakeListFile.Functions.end(), + [target_name](const auto &func) { + return func.LowerCaseName() == "target_sources" + && func.Arguments().size() > 1 + && func.Arguments().front().Value + == target_name; + }); + auto addQmlModuleFunc = std::find_if(cmakeListFile.Functions.begin(), + cmakeListFile.Functions.end(), + [target_name](const auto &func) { + return (func.LowerCaseName() == "qt_add_qml_module" + || func.LowerCaseName() == "qt6_add_qml_module") + && func.Arguments().size() > 1 + && func.Arguments().front().Value + == target_name; + }); - for (const auto &func : {function, targetSourcesFunc}) { + for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc}) { if (func == cmakeListFile.Functions.end()) continue; auto filePathArgument