variable_watch incorrectly interprets escape characters in variable values
It appears variable_watch interprets escape characters in the variable's value before passing it to the given command. Since the value isn't a literal string, this seems like an invalid behaviour.
For example, the following:
function(varwatch var access val lst stack)
message("Variable watch: ${val}")
endfunction()
set(test1 "C:\\tmp\\n")
variable_watch(test1 varwatch)
message("test1 = ${test1}")
results in:
Variable watch: C: mp
test1 = C:\tmp\n
Moreover, if the value happens to include a backslash followed by a character which isn't a valid escape character, an error is triggered. For example, the following:
function(varwatch var access val lst stack)
message("Variable watch: ${val}")
endfunction()
set(test2 "C:\\foo.bin")
variable_watch(test2 varwatch)
message("test2 = ${test2}")
results in:
CMake Warning (dev) at demo.cmake:9223372036854775807 (varwatch):
Syntax error in cmake code at
/tmp/demo.cmake:9223372036854775807
when parsing string
C:\foo.bin
Invalid escape sequence \f
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.
Call Stack (most recent call first):
demo.cmake:7 (message)
This warning is for project developers. Use -Wno-dev to suppress it.
Variable watch: C:\foo.bin
test2 = C:\foo.bin