[CMake] source_group() and solution directories

David.Karr at L-3COM.COM David.Karr at L-3COM.COM
Thu Dec 4 18:53:09 EST 2008


> By directories I mean "Solution Folders", sorry for the confusion.
> This is a feature that allows you to add "Folders" to the solution.
> This has nothing to do with projects. You can add files to these
> solution folders. Solution folders are at the same level tree-wise
> as projects are (Directly under the solution). There are a couple
> of projects that I have that do not have any implementation files
> (Don't ask why lol). For these, I need solution folders since
> creating a project for these won't work- A project needs at least
> 1 CPP file to be usable.

So, for example, I open a .SLN file generated by CMake, look in the 
"Solution Explorer" pane of Visual Studio 2008, and see the infamous 
ALL_BUILD in the list between two of my projects. (I haven't opened
any of these projects yet, so the entire list is at one level of
indentation below the "Solution" icon.)

ALL_BUILD shows up in this list because there's a file 
ALL_BUILD.vcproj in the same directory as my .SLN file in 
the filesystem.  And there are no .CPP files that are built by 
ALL_BUILD itself (though of course ALL_BUILD depends on projects
that do build .CPP files).

I tend to call ALL_BUILD a "project" because it shows up at the 
same level of the hierarchy as all the projects in Solution Explorer 
and because the "proj" in the filename ALL_BUILD.vcproj suggests 
the word "project" to me.  But I suppose technically I should call 
it a "target".

Anyway, I'm pretty sure now I completely misread the earlier email.
Not so sure I read it correctly this time, though.


> I'm hoping source_group() can be used without any project and
> simply add solution folders to the solution.

Actually this seems counterintuitive to me.  There's no other case 
in which SOURCE_GROUP by itself would cause a .VCPROJ file to be 
generated.  And the icon that shows up in Solution Explorer looks 
like a little manila file folder (the kind you could buy at a 
stationery store in 1970, before some genius decided it was a 
synonym for "filesystem directory"), whereas the icon for a 
"project" in Solution Explorer looks completely different 
(but is identical to the icon for ALL_BUILD).  I guess one could 
question why one level of the hierarchy is different from all 
other levels, but it _is_ different (blame the designers of 
Visual Studio) and I think it would be too confusing to 
pretend otherwise.

Also, you specifically don't want any source files in the thing 
you're creating, which seems already to say it's not a "source group".

It seems to me that what you want is a command that you can use 
instead of ADD_LIBRARY or ADD_EXECUTABLE to create a new target. 
Actually I think there are some such commands; maybe one of them 
does what you want (but if so, someone else will have to explain
it, because I don't know how to use any of those commands).
Otherwise, it seems to me you need a new command.

David



More information about the CMake mailing list