View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015407CMakeCMakepublic2015-02-17 09:172016-06-10 14:31
ReporterS. Paris 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformWIN64OSWindowsOS Version8.1 Pro
Product VersionCMake 3.1.3 
Target VersionFixed in Version 
Summary0015407: source_group: Multiple REGEX and Checking
DescriptionIt would be really convenient to have the possibility for source_group to:
1. Specify multiple regular expressions in one or multiple commands:
   source_group("foo" REGULAR_EXPRESSIONS reg0 reg1)
   source_group("foo" REGULAR_EXPRESSION reg2)
   # Would result in "foo" being selected for files matching reg0, reg1, or reg2
2. Check if a source_group has been specified:
   get_source_group("foo" FILES result0 REGULAR_EXPRESSION result1)
   # Would fill result0 with the files defined for "foo" and result1 with the regexps defined for "foo"
Steps To Reproducesource_group("foo" REGULAR_EXPRESSION reg0)
source_group("foo" REGULAR_EXPRESSION reg1)
# from here "foo" group will not be selected anymore for files matching reg0 but not reg1
Additional Information1. should really be a piece of cake to implement, just make "cmsys::RegularExpression GroupRegex" in cmSourceGroup.h a "std::set<cmsys::RegularExpression>" as it is for GroupFiles; update cmSourceGroupCommand.cxx accordingly.

2. is using Makefile->GetSourceGroup() and is even simpler to implement isn't it?
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0037993)
Ben Boeckel (developer)
2015-02-18 10:45

One problem here is this documentation for source_group:

    If a source file matches multiple groups, the *last* group that
    explicitly lists the file with ``FILES`` will be favored, if any.
    If no group explicitly lists the file, the *last* group whose
    regular expression matches the file will be favored.

What happens with this:

    source_group(foo REGULAR_EXPRESSION .*foo.*)
    source_group(bar REGULAR_EXPRESSION .*bar.*)
    source_group(foo REGULAR_EXPRESSION .*baz.*)

for a file named "foobarbaz.cpp"? "bar" is the last group which matches, but "foo" is the group with the last regular expression which matches. IMO, the "bar" group should match since it is implied that each group is checked in order (not the declaration of the regular expressions), but this might be surprising (though documentation can help clarify it).

Also gives me the idea that it might make sense to support properties on source groups for things like FILES and REGULAR_EXPRESSION so that get_property/set_property can be used rather than new commands for querying them. With that, multi-regex could then be done with:

    get_property(sg_regex SOURCE_GROUP foo PROPERTY REGULAR_EXPRESSION)
    set_property(SOURCE_GROUP foo PROPERTY REGULAR_EXPRESSION "(${sg_regex}|new_regex)")
(0037994)
S. Paris (reporter)
2015-02-18 12:14
edited on: 2015-02-18 12:15

What is not explicit in the documentation is that the Regexp is overridden when calling source_group multiple times for the same group.

So what bothers me in your example is that a file call "foo.cpp" will not be matched at all, when I would expect it to be matched by the group "foo" (using the first RegExp).

Regarding the set_property(SOURCE_GROUP foo PROPERTY REGULAR_EXPRESSION "(${sg_regex}|new_regex)"), it indeed makes it possible to check and update the regexp, but it is really not convenient to use...

(0042716)
Kitware Robot (administrator)
2016-06-10 14:29

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.

 Issue History
Date Modified Username Field Change
2015-02-17 09:17 S. Paris New Issue
2015-02-18 10:45 Ben Boeckel Note Added: 0037993
2015-02-18 12:14 S. Paris Note Added: 0037994
2015-02-18 12:15 S. Paris Note Edited: 0037994
2016-06-10 14:29 Kitware Robot Note Added: 0042716
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team