further cmake updates/fixes and fix getopt_long()

* Build: further CMake updates:
- fix CLang not recognized as a gcc-compatible compiler
- support building in a separate directory (generate
  config.h in builddir/include, not sourcedir/include)
- prefer -std=gnu99 over -std=c99
* src/getopt_long.c (getopt_long): fix to match prototype
  (constify the option parameter)