Match dot in regex

I’m having some issue getting CMake to match a literal dot in a regex expression. The following regex works, but doesn’t match a dot:

file(STRINGS "${INPUT_FILE}" VERSION_BRANCH_FRIENDLY REGEX "^[ \t]*#define[ \t]+VERSION_BRANCH_FRIENDLY[ \t]+\"[a-zA-Z0-9_\\-]+\".*$")

If I add a dot to the match it does not match anymore, I’ve tried the following:

file(STRINGS "${INPUT_FILE}" VERSION_BRANCH_FRIENDLY REGEX "^[ \t]*#define[ \t]+VERSION_BRANCH_FRIENDLY[ \t]+\"[a-zA-Z0-9_\\-.]+\".*$")

This tells me the regex failed to compile. Escaping the dot with either one or two backslashes makes it compile but not match anything. How can I match a dot with CMake?

Character - inside [] must be the first or the last character of the range when not used to specify a range (as specified in the Regex Specification).

My, that’s surprising behaviour, given that it’s already escaped. This does solve the issue. Thanks!

FWIW, this behavior isn’t specific to CMake’s regexes; just about every syntax supporting [-] requires - as - (versus “between the adjacent characters”) requires it be at one end or the other.