SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.71k stars 1.12k forks source link

Trigger reconfigure when git commit hash changes #381

Open TheJJ opened 9 years ago

TheJJ commented 9 years ago

When the value of git describe changes, we should trigger a reconfigure when typing make. This ensures the version generated to config.h matches with the actual repository version.

The "dirty" solution would be checking for the version each time, something better would be a update watch on some file in ./.git/, but maybe you have a better idea how cmake may detect a changed HEAD efficiently.

bvbfan commented 8 years ago

cmake-modules has it. https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake

castilma commented 7 years ago

but this does not mean that every file gets recompiled after a git commit/checkout, right?

TheJJ commented 7 years ago

No. It just means that we must ensure that config.cpp is updated once the current git head changes, because that file is generated only when cmake thinks its time for it.

The only file that needs to be recompiled is config.cpp then.

Currently our config.h is recreated, but it is possible to skip it if the preprocessor defines didn't change. The configuration strings (e.g. compiler flags) could be stored in the .cpp only, and declared extern in the .h.