MantisBT - CMake
View Issue Details
0003474CMakeCMakepublic2006-07-03 08:522013-10-07 10:03
Malte Clasen 
Brad King 
lowminoralways
closedfixed 
 
CMake 2.8.11CMake 2.8.11 
0003474: SOURCE_GROUP creates empty groups when using multiple projects
Given the following CMakeLists.txt,

--------------------
SOURCE_GROUP("a1\\a2" "a.cpp")
PROJECT("a")
ADD_LIBRARY("a" STATIC "a.cpp")

SOURCE_GROUP("b1\\b2" "b.cpp")
PROJECT("b")
ADD_LIBRARY("b" STATIC "b.cpp")
--------------------

CMake creates the following project/group hierarchy for Visual C++ 8:

--------------------
a/a1/a2/a.cpp
a/b1
b/a1
b/b1/b2/b.cpp
--------------------

Those groups that contain another group are mirrored into the other project although they are empty in that context.
No tags attached.
patch source_group_targets_dos.patch (10,328) 2009-05-28 21:19
https://public.kitware.com/Bug/file/2288/source_group_targets_dos.patch
patch writeGroups.patch (2,679) 2013-02-04 04:54
https://public.kitware.com/Bug/file/4632/writeGroups.patch
Issue History
2008-07-23 20:07pixman20Note Added: 0012812
2008-07-23 20:09pixman20Note Edited: 0012812
2009-04-19 10:06Mikael HedbergNote Added: 0016071
2009-05-28 21:19Jacob ReppFile Added: source_group_targets_dos.patch
2009-05-28 21:24Jacob ReppNote Added: 0016588
2009-08-14 10:16AmitNote Added: 0017132
2009-08-14 10:16AmitNote Added: 0017133
2009-08-14 10:16AmitNote Deleted: 0017133
2011-09-01 05:25Pjotr SvetachovNote Added: 0027316
2012-10-10 01:39Graham MenhennittNote Added: 0031199
2013-01-24 01:52mika rajalaNote Added: 0032143
2013-02-04 04:54Anton HelwartFile Added: writeGroups.patch
2013-02-04 05:02Anton HelwartNote Added: 0032190
2013-03-08 10:28Brad KingNote Added: 0032540
2013-03-08 10:28Brad KingAssigned ToBill Hoffman => Brad King
2013-03-08 10:28Brad KingStatusassigned => resolved
2013-03-08 10:28Brad KingResolutionopen => fixed
2013-03-08 10:28Brad KingFixed in Version => CMake 2.8.11
2013-03-08 10:28Brad KingTarget Version => CMake 2.8.11
2013-10-07 10:03Robert MaynardNote Added: 0033985
2013-10-07 10:03Robert MaynardStatusresolved => closed

Notes
(0012812)
pixman20   
2008-07-23 20:07   
(edited on: 2008-07-23 20:09)
Can we expect this bug to be fixed in the next version of CMake since it appears that the ticket was submitted over 2 years ago? I am using CMake 2.6 and it is still mirroring the subfolders.

(0016071)
Mikael Hedberg   
2009-04-19 10:06   
I'm also interested in the status of a fix for this bug.
(0016588)
Jacob Repp   
2009-05-28 21:24   
I've attached a patch (with dos line endings) that addresses this issue on the 2.6.4 source release. I ran into this while converting our build system to cmake. This patch adds an optional parameter to source_group which is TARGET. After TARGET you specify the name of the target that the source group exists in. The reason this is done is because source group definitions can exist for multiple targets (even recursively) due to the way that source groups are handled by cmake. This provides you with the most control and flexibility when defining your source groups. The behavior of source groups is not altered when the TARGET parameter is not used.

Example:
SOURCE_GROUP(a1\\a2 TARGET a FILES a.cpp)
PROJECT(a)
ADD_LIBRARY(a STATIC a.cpp)

SOURCE_GROUP(b1\\b2 TARGET b FILES b.cpp)
PROJECT(b)
ADD_LIBRARY(b STATIC b.cpp)
(0017132)
Amit   
2009-08-14 10:16   
I'm interested in a fix of this bug.
(0027316)
Pjotr Svetachov   
2011-09-01 05:25   
We also ran into this bug and while it is just a minor annoyance a fix would be nice.
(0031199)
Graham Menhennitt   
2012-10-10 01:39   
Yes, please fix this. It's very annoying.

Thanks
(0032143)
mika rajala   
2013-01-24 01:52   
6 years later and no fix?

I'm supposed to try and "sell" cmake usage to my teammates today and this bug is bound to come up.

Please fix this!
(0032190)
Anton Helwart   
2013-02-04 05:02   
Hi,

I wrote a small patch (writeGroups.patch) to fix this problem in the Visual Studio 7 generator.
It makes the WriteGroup methode return true, if a group or any of its
children have source files.
The children write their output to a temporay cmOStringStream and its only
added to the real output, if it is not empty.
I hope the patch can be of some use.

Regards, Anton
(0032540)
Brad King   
2013-03-08 10:28   
Re 0003474:0032190: Thanks for the patch. Applied:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=545fdec4 [^]

It appears this problem does not occur in the VS 10 and 11 generators, so I'm resolving this issue.
(0033985)
Robert Maynard   
2013-10-07 10:03   
Closing resolved issues that have not been updated in more than 4 months.