added cmake build system, mostly complete #869