MantisBT - CMake
View Issue Details
0013425CMakeCMakepublic2012-07-19 07:512016-06-10 14:31
S. Paris 
Kitware Robot 
normalminoralways
closedmoved 
winwin7 64
CMake 2.8.8 
 
0013425: source_group displays empty groups (when nesting)
Issue applicable for Visual Studio projects.

When using source_group to define nested groups with some files, those groups are displayed even if they do not contain files for a given target.

In my case, I have two targets, with source_groups defined for target#1 and containing some files. Those files being referenced as sources for target#1, they are displayed correctly and classified in the good group.
But, those files not being part of target#2, the groups are still displayed in the Visual Studio project (but the most nested group).

Even if this issue is non-blocking, it is a pain in my case where I classify lots of sources in groups for several targets in the same project. It results with a lot of noisy empty groups in all of my projects.
Just put the following wherever in your CMakeLists.txt, and build using a Visual Studio generator (the files do not have to be referenced).

source_group(test FILES test)
source_group(test\\test1 FILES test1)
source_group(test\\test1\\test2 FILES test2)

As a result, you will see the following empty project folders for your target:
|-test
| |-test1
I assume that there is a bug in the CMake source code when checking if a group must be displayed or not: the group is tested to be empty, but accounting for sub-groups as well without recursing through them to check if themselves are empty as well. That would explain why the hierarchy of empty groups does not display the last empty group (this one not having any file nor sub-group).
No tags attached.
Issue History
2012-07-19 07:51S. ParisNew Issue
2012-07-19 08:01S. ParisNote Added: 0030084
2016-06-10 14:28Kitware RobotNote Added: 0042094
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0030084)
S. Paris   
2012-07-19 08:01   
Oups, duplicates this one: http://public.kitware.com/Bug/view.php?id=13424 [^]
(0042094)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.