[CMake] What does this mean: IF("${VARIABLE}" MATCHES "^${VARIABLE}$")

Jian Wang jwang at a10networks.com.cn
Tue Dec 11 08:04:27 EST 2007


On Dec 11, 2007 6:49 PM, Pau Garcia i Quiles <pgquiles at elpauer.org> wrote:

> Quoting "Clark J. Wang" <dearvoid at gmail.com>:
>
> > The header of many CMake modules often looks like this (take
> > CheckIncludeFile as an example):
> >
> > MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
> >   IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
> >   ... ...
> >
> > The IF statement really puzzles me a lot. What is it used to do?
> >
>
> In strings it would mean "if this string is exactly equal to". The
> caret (^) represents string beginning and the $ represents string end.
>
> Why is IF("${VARIABLE}" MATCHES "^${VARIABLE}$") used instead of IF(
> ${VARIABLE} STREQUAL ${VARIABLE} ) (which would always return true)?
> I'm not sure of use case but I'd say it's checking for special
> characters in VARIABLE.

If it's checking for special characters then I have to say that it's not the
right way. For example, if VARIABLE == "a/b" then the IF statement is still
TRUE.

>
>
> --
> Pau Garcia i Quiles
> http://www.elpauer.org
> (Due to my workload, I may need 10 days to answer)
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20071211/d25e9115/attachment.htm


More information about the CMake mailing list