For example, one might want to use the install() command to run CMake code at install time. Code of this form is usually something like:
install(CODE "
message(STATUS "The value of \${VAR} is \"\${VAL}\"
")
In this case, each $ is escaped as we want the expansion to be performed at install time, not when the string is first parsed by CMake. In addition, nested quotes also need to be escaped. For larger commands, this can quickly become onerous -- it can be easy to forget to escape quotes and $s.
Is there a better way?