Has anyone got any suggestions for a CMake-based JUCE project, to include the current git hash as a Build ID in the project - the idea is so that we can easily recognize the latest commit of the project in the version.
I’ve looked at adding a hash to the VERSION file, but I’d kind of like something a bit more future-proof, so we can keep pace with whatever CMake changes occur with JUCE in the future.
In other words, we want to include the output of this command in a string somewhere - in JuceHeader.h? - in order to identify builds easily in the future:
git rev-parse --short HEAD
Is there a ‘proper’ place to put this in our CMakeLists.txt - or maybe this would be a cool feature to add to future JUCE versions’ CMake scripts, somehow?
Thanks folks, those are both really great answers - I like the succinct nature of @eyalamir 's approach, but I’m going to go ahead and incorporate @zsliu98 's CMake code, as that allows for a bit more flexible approach in different build scenarios.
Might have to see if this can be pushed upstream to PampleJuce/JUCE official, also. Just seems to me to be so useful to be able to click the plugin version string and get the build hash in the future …
I think something like that totally belongs in user space and has no place in JUCE.
But in your build scripts - why not? You can make it a CMake function and expose it across multiple projects (just don’t use something like add_definitions since it’s global, and you might have multiple git repos).
Oh, I saw it more of an extension of the VERSION file mechanism, just as an added value for service/support requests, when chasing down bugs - but yeah … its no problem either way to just add the code to include the Build ID in my own CMake scripts.