forked from qt-creator/qt-creator
CMakePM: Do not show subfolders for custom source_groups
CMake does have a few default source groups (cmMakefile.cxx):
this->AddSourceGroup("", "^.*$");
this->AddSourceGroup("Source Files", CM_SOURCE_REGEX);
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
this->AddSourceGroup("Precompile Header File", CM_PCH_REGEX);
this->AddSourceGroup("CMake Rules", "\\.rule$");
this->AddSourceGroup("Resources", CM_RESOURCE_REGEX);
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
This commit will get Qt Creator to display the actual subfolder
structure only if the CMake setting "Show subfolders inside source group
folders" is set and for "Source Files" and "Header Files" source groups.
Any other source group or a custom source group defined by `source_group`
will not get this treatment, since this what the oder IDEs (e.g. Visual
Studio) and what the users expect to have.
Task-number: QTCREATORBUG-27432
Fixes: QTCREATORBUG-30620
Change-Id: I3c30814df2f76d18ee5fd4fd1356d4dfc4b9b09b
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -654,7 +654,6 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
||||
const FilePath &buildDirectory,
|
||||
const TargetDetails &td)
|
||||
{
|
||||
const bool showSourceFolders = settings().showSourceSubFolders();
|
||||
const bool inSourceBuild = (sourceDirectory == buildDirectory);
|
||||
|
||||
QSet<FilePath> alreadyListed;
|
||||
@@ -685,6 +684,9 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
||||
if (isPchFile(buildDirectory, sourcePath) || isUnityFile(buildDirectory, sourcePath))
|
||||
node->setIsGenerated(true);
|
||||
|
||||
const bool showSourceFolders = settings().showSourceSubFolders()
|
||||
&& sourcesOrHeadersFolder(td.sourceGroups[si.sourceGroup]);
|
||||
|
||||
// Where does the file node need to go?
|
||||
if (showSourceFolders && sourcePath.isChildOf(buildDirectory) && !inSourceBuild) {
|
||||
buildFileNodes.emplace_back(std::move(node));
|
||||
@@ -696,6 +698,9 @@ static void addCompileGroups(ProjectNode *targetRoot,
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sourceGroupFileNodes.size(); ++i) {
|
||||
const bool showSourceFolders = settings().showSourceSubFolders()
|
||||
&& sourcesOrHeadersFolder(td.sourceGroups[i]);
|
||||
|
||||
std::vector<std::unique_ptr<FileNode>> ¤t = sourceGroupFileNodes[i];
|
||||
FolderNode *insertNode = td.sourceGroups[i] == "TREE"
|
||||
? targetRoot
|
||||
|
||||
@@ -18,6 +18,11 @@ using namespace ProjectExplorer;
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
bool sourcesOrHeadersFolder(const QString &displayName)
|
||||
{
|
||||
return displayName == "Source Files" || displayName == "Header Files";
|
||||
}
|
||||
|
||||
std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
||||
int priority,
|
||||
const QString &displayName)
|
||||
@@ -25,8 +30,7 @@ std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
||||
auto newFolder = std::make_unique<VirtualFolderNode>(basePath);
|
||||
newFolder->setPriority(priority);
|
||||
newFolder->setDisplayName(displayName);
|
||||
newFolder->setIsSourcesOrHeaders(displayName == "Source Files"
|
||||
|| displayName == "Header Files");
|
||||
newFolder->setIsSourcesOrHeaders(sourcesOrHeadersFolder(displayName));
|
||||
return newFolder;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
bool sourcesOrHeadersFolder(const QString &displayName);
|
||||
|
||||
std::unique_ptr<ProjectExplorer::FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
|
||||
int priority,
|
||||
const QString &displayName);
|
||||
|
||||
Reference in New Issue
Block a user