[CMake] if(string MATCHES regex) question
Eric Noulard
eric.noulard at gmail.com
Wed Jul 1 12:28:57 EDT 2009
2009/7/1 Marcel Loose <loose at astron.nl>:
> Hi all,
>
> In a number of standard CMake modules I encountered the following line:
>
> IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
>
> Can anyone explain the rationale of this conditional to me.
The rational no but ....
> To my cluttered mind this seems to be an "always-true" condition.
this is definitely not always true.
The variable your are testing may contain "un-evaluated" var
or some special regex character( *, ?, ...)
See attached example, you may test it with
$ cmake -P matches.cmake
MATCHES -- MYVAR = A good var
Look that one = double-dollar = blah / single-dollar = MYVAR2
NO MATCHES ** MYVAR = MYVAR2
$
However I have no such usage currently :-)
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: matches.cmake
Type: application/octet-stream
Size: 544 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090701/3494235c/attachment.obj>
More information about the CMake
mailing list