[CMake] Re: POSIX regex support

Brandon Van Every bvanevery at gmail.com
Fri Aug 10 15:55:17 EDT 2007


On 8/10/07, Pau Garcia i Quiles <pgquiles at elpauer.org> wrote:
> Quoting Bill Hoffman <bill.hoffman at kitware.com>:
>
> > Pau Garcia i Quiles wrote:
> >>
> >> I took a quick look a few weeks ago and replacing the current regex
> >>  library with PCRE seems "easy" (most of the work would be
> >> replacing  the regexp's in current .cmake files with their POSIX
> >> equivalents).  Is Kitware or anyone else already working on that?
> > Sounds like a backwards compatibility problem....   I am sure we would
> > break tons of projects if we changed the REGEX format in cmake.
> >
> >
> > -Bill
>
> That was my first thought, too, but we could keep backwards
> compatibility easily.
>
> It'd just be a matter of having something like:
> SET( REGULAR_EXPRESSIONS CMAKE_CLASSICAL)
> or
> SET( REGULAR_EXPRESSIONS POSIX)

Not the worst idea I've heard, but the scoping is definitely error prone.

> Even better, prepending an unusual-enough character we could have both
> regular expressions at once in the same project.

A questionable design goal, although perhaps justified for
intermediate migration purposes.

> Say we decide "~" is
> that character. If we write STRING( REGEX_MATCH "whatever" MYOUTVAR
> ${MYINPUTTEXT} ) CMake uses current regular expressions, if we write
> STRING( REGEX_MATCH "~whatever" MYOUTVAR ${MYINPUTTEXT} ) CMake uses
> POSIX regular epxressions. To match "~" we would use it escaped: "\~".

Totally horrible brain dead idea.  If it weren't for your other
suggestions, I'd say you should be shot.

> Another option would be to have something like STRING(
> POSIX_REGEX_MATCH ...), etc

Yes please.  No compatibility problems with that.  Although I think
STRING(POSIX_REGEX MATCH ...)
STRING(POSIX_REGEX REPLACE ...)
is the way to go, rather than lumping everything into 1 keyword.  Or
STRING(PCREGEX MATCH ...)
STRING(PCREGEX REPLACE ...)
since we're really talking "Perl Compatible Regular Expressions"
rather than POSIX, aren't we?

Make sure there's also a way to select non-greedy operators.  This is
really important.  I don't know how PCRE or POSIX does it.

> but I like the "~" better.

You are a sick, depraved individual.


Cheers,
Brandon Van Every


More information about the CMake mailing list