[cmake-developers] [CMake 0013126]: SOURCE_GROUP does not work for regular expressions AND no-name groups

Mantis Bug Tracker mantis at public.kitware.com
Fri Apr 13 06:47:05 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13126 
====================================================================== 
Reported By:                kislinsk
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13126
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-04-13 06:47 EDT
Last Modified:              2012-04-13 06:47 EDT
====================================================================== 
Summary:                    SOURCE_GROUP does not work for regular expressions
AND no-name groups
Description: 
CMake creates the default source groups (in context of MSVC "filters") "Header
Files" and "Source Files" for convenience and puts all files to the appropriate
group. This behavior can be overwritten by specifying own source groups and put
each and every file to them. If there is any file left, both default source
groups will be created. OK, fine so far.

Imagine the following scenario where you want to put each file into a source
group that matches its path:

Foo.h
Foo.cpp
Bar/Bar.h
Bar/Bar.cpp

The following snippet works:

source_group("" FILES Foo.h Foo.cpp) # no-name group -> no filter
source_group(Bar FILES Bar/Bar.h Bar/Bar.cpp)
add_executable(FooBar Foo.h Foo.cpp Bar/Bar.h Bar/Bar.cpp)

No "Header Files" nor "Source Files" filters are generated, only the "Bar"
filter containing Bar.h and Bar.cpp. Foo.h and Foo.cpp are located at the top
level of the project. Perfect!

Of course you have more files in a real world scenario so you may prefer to use
the regular expression versions of source_group which work well except for the
case of a no-name group:

source_group("" "[^/]+\\.(cpp|h)") # BUG!
source_group(Bar "Bar/[^/]+\\.(cpp|h)")

For simplicity you can reduce the regular expressions to something like
"Foo\\.(cpp|h)" and "Bar/Bar\\.(cpp|h)", it doesn't matter.

With a regular expression no-name groups do not work at all. "Header Files" and
"Source Files" filters are created and everything is put into them instead.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-04-13 06:47 kislinsk       New Issue                                    
======================================================================




More information about the cmake-developers mailing list