message("$ENV{ProgramFiles\(x86\)}")
gives a warning and doesn’t output what we want:
CMake Warning (dev) at D:/dev/CMExt/env_var.cmake:1 (message):
Syntax error in cmake code at
D:/dev/CMExt/env_var.cmake:1
when parsing string
$ENV{ProgramFiles\(x86\)}
syntax error, unexpected cal_SYMBOL, expecting } (19)
Policy CMP0010 is not set: Bad variable reference syntax is an error. Run
"cmake --help-policy CMP0010" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
$ENV{ProgramFiles\(x86\)}
cmake_policy(SET CMP0010 NEW)
message("$ENV{ProgramFiles\(x86\)}")
gives an error and stops processing:
CMake Error at D:/dev/CMExt/env_var.cmake:2 (message):
Syntax error in cmake code at
D:/dev/CMExt/env_var.cmake:2
when parsing string
$ENV{ProgramFiles\(x86\)}
syntax error, unexpected cal_SYMBOL, expecting } (19)
cmake_policy(SET CMP0053 NEW)
message("$ENV{ProgramFiles\(x86\)}")
gives what we want:
C:\Program Files (x86)