When using cmake
, we wish for our distibutable files to contain some information about the release itself (such as a git
tag or commit point). This is so we can basically tell from the installed package alone what release it is.
In other words, we're looking for something like the output of git show | head -1
:
commit 695ec2ceca0854...blahblahblah
Our cmake
files are fairly simple, consisting of:
add_executable(exename main.cpp functions.cpp functions.h)
How do we configure CMakeLists.txt
to both generate this information and include it in the packaging for the project.
This could be baked in to the executable as a file with one string object like:
char *x = "XYZZY-commit 695ec2ceca0854...blahblahblah";
so that we can run strings
on the executable to get the information.
It could also be a totally separate file like commitpoint.txt
which is packaged and shipped with the executable.
Or, if anyone has a better way of doing this, I'm open to suggestions.
What I'd prefer to avoid is something that requires manual intervention when building, such as maintaining a module with the information hard-coded into it and stored in git
itself. I'm looking for something that's fully automated.