Cmake build

This should make it so that the cmake build works again with close to the minimal amount of changes.