stealing the cmake stuff from https://github.com/woboq/moc-ng
fixing cmake stuff so it can build as standalone