[Cmake] case sensitive string matching ?

Bill Hoffman bill . hoffman at kitware . com
Tue, 01 Jul 2003 11:06:05 -0400


The MATCHES uses a regular expression, not a wild card.
Here are the meanings of the metacharacters in the cmake regular expression:


 *  ^        Matches at beginning of a line
 *
 *  $        Matches at end of a line
 *
 * .         Matches any single character
 *
 * [ ]       Matches any character(s) inside the brackets
 *
 * [^ ]      Matches any character(s) not inside the brackets
 *
 *  -        Matches any character in range on either side of a dash
 *
 *  *        Matches preceding pattern zero or more times
 *
 *  +        Matches preceding pattern one or more times
 *
 *  ?        Matches preceding pattern zero or once only
 *
 * ()        Saves a matched expression and uses it in a  later match
 

So "A*" means, match 0 or more times, and "ab" matches 0 times so, it is a match.

What you want is this:

IF("ab" MATCHES "a+")
 MESSAGE("++++   ab matches a* ")
ENDIF("ab" MATCHES "a+")


IF("ab" MATCHES "A+")
 MESSAGE("++++   ab matcheses A* ")
ENDIF("ab" MATCHES "A+")



At 10:53 AM 7/1/2003, Jan Woetzel wrote:
>Hi,
>
>is there a way to do case sensitive string matching?
>
>In IF matching seems to be case insensitive,
>both of teh following versions match:
>
>IF("ab" MATCHES "a*")
> MESSAGE("++++   ab matches a* ")
>ENDIF("Aab" MATCHES "A*")
>
>IF("ab" MATCHES "A*")
> MESSAGE("++++   ab matcheses A* ")
>ENDIF("ab" MATCHES "A*")
>
>
>Background:
>There are third party configure --cflags and configure--libs scripts I want to use.
>Their output is a mix of libs and link directories.
>I want to sort the libs out by "-l*" and teh link directopries by "-L*".
>
>I want to avoid putting a backquoted `config --libs` into to CMAKE_CXX_FLAGS to get rpath running correctly.
>
>I am refering to cmake Version 1.6.7 under Linux.
>
>Best regards,
>Jan.