It seems that many projects may be able to automatically detect source code version from git tags but many don’t do it. I have also found other versions of similar scripts that are able to detect Git versions but it is difficult to locate a single source for a maintained alternative.
For the above reasons, I wanted to share my take on Git version detection for CMake projects. You can find it at GitHub - antoniovazquezblanco/cmake-gitversiondetect: Make GIT versioning info available in your CMakeLists.txt file
Any feedback would be apreciated! Thanks!
1 Like
Lecris
(Cristian Le)
June 7, 2023, 12:43pm
2
I’ve also worked on something like that here , so I can offer a few tips:
support .git_archival.txt
for git archives
needs a target that would re-trigger builds when a commit/tag is created
git describe tags
should allow for different version formats
packaging for other projects to use via FetchContent/find_package?
1 Like
Thank you @Lecris for the pointers. I see your DynamicVersion script is quite nicely packed with features I did not even thought I needed!
Awesome!
shabiel
(Sam Habiel)
June 8, 2023, 5:04pm
4
2 Likes
Wow! It even has testing! I see it also detects git changes!
I am quite new to CMake but those examples really help me improve this and maybe other modules I may try to implement soon.
Thank you!