File by Corentin Noël, with some CMake machinery changes by me to generate the version / data automatically.