Add libgit2 dependency to build system

This is pretty much #7339 with all changes to base removed. And I'm changing the way I'm handling flags and compiler names with cmake in the last commit.
We can turn them off to save build time, I think I have them commented out