Cmake config new

Rebased version of #155 to get rid of the ugly merge mess.

Also added the config.h name change for autoconf in this one.