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

Brandon Van Every bvanevery at gmail.com
Tue Dec 11 13:37:32 EST 2007


On Dec 11, 2007 8:16 AM, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Jian Wang wrote:
>
> >     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.
>
> It is checking to see if the VARIABLE has a value at all.  It is old
> code before we had IF(DEFINED VARIABLE) but works with all versions of
> CMake.

One of these days I'm going to try to construct a pathological input
to make it barf.  But I've still got other priorities.


Cheers,
Brandon Van Every


More information about the CMake mailing list