MantisBT - CMake
View Issue Details
0009863CMakeCMakepublic2009-11-07 11:512010-06-11 16:04
chrislu 
Brad King 
normalmajoralways
closedfixed 
CMake-2-8 
 
0009863: source_groups not (always) working for Visual Studio 10 beta2
file(GLOB SOURCE_FILES ../sick_sad_world/*.cpp)
list(APPEND PROJ_SOURCE_FILES ${SOURCE_FILES})
source_group(source_files/sick_sad_world FILES ${SOURCE_FILES})

when adding files to source groups without any files in the root source file. the source groups are missing in Visual Studio 10, even some files are not visible. when regarding the generated .vcxproj and vcxproj.filters files everything looks normal. so i think this could be an issue of VS10. BUT, when using a native solution/project file it is possible to create such a scenario.

i created a repro case (attached file). when you add the commented part in the CMakeLists.txt file everything works as expected. this part only adds a dummy file to the root source_group.
No tags attached.
has duplicate 0010154closed  Visual Studio 2010 source groups are not generated correctly for nested sources 
has duplicate 0010555closed  source_groups not working as expected for Visual Studio 10 
zip sick_sad_world_cmake_vs10.zip (1,042) 2009-11-07 11:51
https://public.kitware.com/Bug/file/2641/sick_sad_world_cmake_vs10.zip
patch 9863.patch (3,330) 2010-05-19 16:20
https://public.kitware.com/Bug/file/3129/9863.patch
patch chrisw_9863_2.patch (3,331) 2010-05-26 15:49
https://public.kitware.com/Bug/file/3144/chrisw_9863_2.patch
patch diff.patch (2,906) 2010-06-10 16:40
https://public.kitware.com/Bug/file/3180/diff.patch
Issue History
2009-11-07 11:51chrisluNew Issue
2009-11-07 11:51chrisluFile Added: sick_sad_world_cmake_vs10.zip
2009-11-29 15:46Jack WhiteheadNote Added: 0018613
2009-12-10 11:26chrisluNote Added: 0018795
2010-02-26 06:57chrisluNote Added: 0019640
2010-04-13 14:48chrisluNote Added: 0020164
2010-05-08 06:56cbielowNote Added: 0020659
2010-05-08 07:21cbielowNote Added: 0020662
2010-05-19 16:20chriswFile Added: 9863.patch
2010-05-19 16:22chriswNote Added: 0020792
2010-05-19 16:26chriswNote Edited: 0020792
2010-05-20 09:59chriswNote Added: 0020801
2010-05-26 13:24Bill HoffmanStatusnew => assigned
2010-05-26 13:24Bill HoffmanAssigned To => Bill Hoffman
2010-05-26 15:49chriswFile Added: chrisw_9863_2.patch
2010-05-26 15:53chriswNote Added: 0020830
2010-06-07 13:45chriswNote Added: 0020933
2010-06-10 16:39cbielowNote Added: 0020985
2010-06-10 16:40cbielowFile Added: diff.patch
2010-06-10 16:41cbielowNote Edited: 0020985
2010-06-10 16:56chriswNote Added: 0020986
2010-06-11 13:53Bill HoffmanAssigned ToBill Hoffman => Brad King
2010-06-11 16:04Brad KingNote Added: 0020996
2010-06-11 16:04Brad KingStatusassigned => closed
2010-06-11 16:04Brad KingResolutionopen => fixed
2010-06-11 16:04Brad KingRelationship addedhas duplicate 0010154
2010-06-11 16:05Brad KingRelationship addedhas duplicate 0010555

Notes
(0018613)
Jack Whitehead   
2009-11-29 15:46   
I came across this problem too and have realised what the problem is. The *.filters file generator simply needs to declare a separate filter for those groups that have no files. For example:

# Foo group is empty (i.e. it has no files directly):
source_group( Foo\\Bar FILES main.cpp )

There needs to be the following in the .filters file:

<Filter Include="Foo">
  <UniqueIdentifier>{ %GUID% }</UniqueIdentifier>
</Filter>

In addition to this (which is currently being generated)

<Filter Include="Foo\Bar">
  <UniqueIdentifier>{ %GUID% }</UniqueIdentifier>
</Filter>
(0018795)
chrislu   
2009-12-10 11:26   
yes, i can confirm this.
(0019640)
chrislu   
2010-02-26 06:57   
confirmed for Visual Studio 2010 RC1
(0020164)
chrislu   
2010-04-13 14:48   
confirmed with Visual Studio 2010 final version!

This is a show stopper, completely unusable.
(0020659)
cbielow   
2010-05-08 06:56   
I can confirm this too:
VS 2010 RC1 10.0.30128.1
(0020662)
cbielow   
2010-05-08 07:21   
identical to
http://www.cmake.org/Bug/view.php?id=10154 [^]
and
http://www.cmake.org/Bug/view.php?id=10555 [^]
(0020792)
chrisw   
2010-05-19 16:22   
(edited on: 2010-05-19 16:26)
Hi,
I created a patch to fix this (actually at least half of the credit goes to Jack Whitehead who figured this out).

/edit:
See 9863.patch. I just realized I accidentally added an unnecessary "#include <algorithm>", unfortunately I can't seem to withdraw and re-upload my attachment.

(0020801)
chrisw   
2010-05-20 09:59   
Looks like my patch doesn't always work. I guess I'll look into this next weekend.
(0020830)
chrisw   
2010-05-26 15:53   
I think I got it now, just a dumb mistake on my part. Uploaded an amended version of my patch -> chrisw_9863_2.patch
(0020933)
chrisw   
2010-06-07 13:45   
Anyone interested in reviewing my patch?
(0020985)
cbielow   
2010-06-10 16:39   
(edited on: 2010-06-10 16:41)
I used
git clone -b release git://cmake.org/cmake.git [^] CMakeRel
then applied your patch (required some conflict resolution but 'AddMissingSourceGroups(groupsUsed, sourceGroups);' is unchanged)
and compiled CMake.

WORKS LIKE A CHARM!
(Win7 64bit, VS2010 10.0.30128.1 RC1Rel)

(I'll attach the new patch [diff.patch] in case its needed. I really don't know in which branch it belongs)

(0020986)
chrisw   
2010-06-10 16:56   
Thanks for your feedback. Looks like I forgot to mention that my patch (chrisw_9863_2.patch) belongs to tag v2.8.1 - sorry about that.
(0020996)
Brad King   
2010-06-11 16:04   
I've pushed out the fix to next:

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