forked from qt-creator/qt-creator
CMakePM: Fix display of header / source files
Qt Creator will display the header / source files based on the
sourceDirectory of the target as base directory.
The source_group(TREE <dir>) will result CMake in making a source group
named "TREE" which should not be displayed in the project view.
Amends 9280f7f757
Fixes: QTCREATORBUG-23942
Fixes: QTCREATORBUG-29105
Change-Id: Ib71ffcc559376ea1596a5b21cb7e7fa779bd8d79
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -644,29 +644,18 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate base directory for source groups:
|
|
||||||
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
|
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
|
||||||
std::vector<std::unique_ptr<FileNode>> ¤t = sourceGroupFileNodes[i];
|
std::vector<std::unique_ptr<FileNode>> ¤t = sourceGroupFileNodes[i];
|
||||||
FilePath baseDirectory;
|
FolderNode *insertNode = td.sourceGroups[i] == "TREE"
|
||||||
// All the sourceGroupFileNodes are below sourceDirectory, so this is safe:
|
? targetRoot
|
||||||
for (const std::unique_ptr<FileNode> &fn : current) {
|
: createSourceGroupNode(td.sourceGroups[i],
|
||||||
if (baseDirectory.isEmpty()) {
|
sourceDirectory,
|
||||||
baseDirectory = fn->filePath().parentDir();
|
targetRoot);
|
||||||
} else {
|
|
||||||
baseDirectory = FileUtils::commonPath(baseDirectory, fn->filePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FolderNode *insertNode = createSourceGroupNode(td.sourceGroups[i],
|
|
||||||
baseDirectory,
|
|
||||||
targetRoot);
|
|
||||||
|
|
||||||
if (showSourceFolders) {
|
if (showSourceFolders) {
|
||||||
insertNode->addNestedNodes(std::move(current), baseDirectory);
|
insertNode->addNestedNodes(std::move(current), sourceDirectory);
|
||||||
} else {
|
} else {
|
||||||
for (auto &fileNodes : current) {
|
for (auto &fileNodes : current)
|
||||||
insertNode->addNode(std::move(fileNodes));
|
insertNode->addNode(std::move(fileNodes));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user