cmake: handle missing git or .git/