Should be variable name instead of variable reference. If the variable is somehow unset, it messes up the if condition expression and causes a CMake error.
You are absolutely right, thanks for spotting this!