[RDY] cmake: handle missing git or .git/

re https://github.com/neovim/neovim/issues/1292

Use @xu-cheng 's commit to try to get the commit for homebrew users. Failing that, it will simply leave out the "pre release" portion of the version (i.e., it will show ` NVIM 0.0.0-alpha` instead of `NVIM 0.0.0-alpha+HEAD-HASH-NOTFOUND`).