Open TheJJ opened 9 years ago
cmake-modules has it. https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake
but this does not mean that every file gets recompiled after a git commit/checkout, right?
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
.
When the value of
git describe
changes, we should trigger a reconfigure when typingmake
. This ensures the version generated toconfig.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.