calling `sed -i` is evil, let's use cmake's configure_file() instead

`configure_file()` can generate a file based on a template, so let's use this instead of `sed` inplace. also clean the generated file in the clean target, so the do not pollute the checkout.