[Cmake] Substitution or not between quotes?
Brad King
brad.king at kitware.com
Sun Aug 22 10:23:47 EDT 2004
Martin Trudeau wrote:
> Hi.
>
> Could anyone explain to me why
>
> #################
> IF("y" MATCHES "^y$")
> MESSAGE("match")
> ELSE("y" MATCHES "^y$")
> MESSAGE("no match")
> ENDIF("y" MATCHES "^y$")
> ###################
>
> produces the message "match" if y is not defined
> but "no match" if it is. I thought there was never any
> substitution taking place for strings between quotes, unless
> ${...} was used. So, if there is substitution, why and how?
The IF command has a special case for backward compatibility with very
early CMake versions. It allows the following to work:
IF(CMAKE_SOME_VAR MATCHES "^regex$")
ENDIF(CMAKE_SOME_VAR MATCHES "^regex$")
This is testing whether the contents of the variable CMAKE_SOME_VAR
match the regular expression. The behavior is documented here:
http://www.cmake.org/HTML/Documentation.html
The presence of the quotes in the first argument of an IF command has no
effect unless a ${...} is present.
-Brad
More information about the Cmake
mailing list