[CMake] Accessing ${SITE} in CTestConfig.cmake

Kyle Edwards kyle.edwards at kitware.com
Mon Dec 31 14:00:21 EST 2018


On Mon, 2018-12-31 at 13:50 -0500, Donald MacQueen [|] wrote:
> Thanks very much Kyle. I guess I am not real clear about when vars
> should be used as var versus ${var}.

Generally speaking, you use var when setting a variable, and ${var}
when reading its value. It's a lot like how shell variables are used in
bash:

foo=bar
echo $foo

if() and while() break this convention because they were written very
early in CMake's history, before there was a concept of variable
expansion.

However, because of CMP0054, you can put ${var} in quotes:

if("${foo}" STREQUAL "bar")

and it will have the same effect as:

if(foo STREQUAL "bar")

See https://cmake.org/cmake/help/latest/policy/CMP0054.html for
details.

Kyle


More information about the CMake mailing list