CMakePM: Do not add sources to globbed targets

If a class is being added to a target that has a variable resulted from
a `file(GLOB|_RECURSE)` call, we skip adding the files to the target.

Do not add the files, just run CMake which would gather the new sources
into the project.

Adding sources to a globbed target will no longer open the
CMakeLists.txt file, since nothing has changed.

CMake will be run after adding, renaming and removing of sources files.

Fixes: QTCREATORBUG-30445
Change-Id: I82e126737789f215a6400f5a43f303dcc57de005
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-03-01 14:21:10 +01:00
parent 313ed327be
commit 030e3c2cd5
3 changed files with 95 additions and 60 deletions

View File

@@ -187,9 +187,16 @@ void CMakeTargetNode::setConfig(const CMakeConfig &config)
m_config = config;
}
void CMakeTargetNode::setVisibleAfterAddFileAction(bool visibleAfterAddFileAction)
{
m_visibleAfterAddFileAction = visibleAfterAddFileAction;
}
std::optional<FilePath> CMakeTargetNode::visibleAfterAddFileAction() const
{
return filePath().pathAppended(Constants::CMAKE_LISTS_TXT);
if (m_visibleAfterAddFileAction)
return filePath().pathAppended(Constants::CMAKE_LISTS_TXT);
return std::nullopt;
}
void CMakeTargetNode::build()