forked from qt-creator/qt-creator
cmake: Add option to disable subfolders
An option is added to change the default behavior that would create subfolders inside source groups for files based on their location on disk. When disabling the option, files will be added directly under their respective source group. The virtual folders <build-folder> and <other-files> is also omitted when the option is disabled. Fixes: QTCREATORBUG-27432 Change-Id: Id78e178011c5299d4f7257bf855a5d791eebf91c Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "fileapidataextractor.h"
|
||||
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "fileapiparser.h"
|
||||
#include "projecttreehelper.h"
|
||||
|
||||
@@ -548,6 +550,9 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const TargetDetails &td)
|
||||
{
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
const bool showSourceFolders = settings->showSourceSubFolders.value();
|
||||
|
||||
const bool inSourceBuild = (sourceDirectory == buildDirectory);
|
||||
|
||||
std::vector<std::unique_ptr<FileNode>> toList;
|
||||
@@ -580,9 +585,9 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
node->setIsGenerated(true);
|
||||
|
||||
// Where does the file node need to go?
|
||||
if (sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
|
||||
if (showSourceFolders && sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
|
||||
buildFileNodes.emplace_back(std::move(node));
|
||||
} else if (sourcePath.isChildOf(sourceDirectory)) {
|
||||
} else if (!showSourceFolders || sourcePath.isChildOf(sourceDirectory)) {
|
||||
sourceGroupFileNodes[si.sourceGroup].emplace_back(std::move(node));
|
||||
} else {
|
||||
otherFileNodes.emplace_back(std::move(node));
|
||||
@@ -605,7 +610,14 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
FolderNode *insertNode = createSourceGroupNode(td.sourceGroups[i],
|
||||
baseDirectory,
|
||||
targetRoot);
|
||||
insertNode->addNestedNodes(std::move(current), baseDirectory);
|
||||
|
||||
if (showSourceFolders) {
|
||||
insertNode->addNestedNodes(std::move(current), baseDirectory);
|
||||
} else {
|
||||
for (auto &fileNodes : current) {
|
||||
insertNode->addNode(std::move(fileNodes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addCMakeVFolder(targetRoot,
|
||||
|
||||
Reference in New Issue
Block a user