CMakePM: Fix adding qml files to targets using ${PROJECT_NAME}

Instead of looking after the target name reported by CMake's file api
e.g. mytarget, take the parameter name from the function that created
the target.

This way if the user used ${PROJECT_NAME} to mark the name of the target
for qt_add_executable and qt_add_qml_module, when adding a qml file the
proper function would be picked.

Fixes: QTCREATORBUG-30218
Change-Id: I920f16d9f5a6b8a7a2fddb3ef7e97e0e3bccd464
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-01-17 20:11:02 +01:00
parent 636faf30db
commit 5e6f1f5dac

View File

@@ -324,7 +324,7 @@ bool CMakeBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FileP
// Special case: when qt_add_executable and qt_add_qml_module use the same target name
// then qt_add_qml_module function should be used
const std::string target_name = targetName.toStdString();
const std::string target_name = function->Arguments().front().Value;
auto add_qml_module_func
= std::find_if(cmakeListFile.Functions.begin(),
cmakeListFile.Functions.end(),