I have a question that I know must have been solved a thousand times before, but I'd like to get the community's opinion on best practices.

In short: how should I manage the version string of my targets? Each target (library or executable) will conceptually have a unique version number, and I'd like to be able to query the versions of all libraries in use by an executable (as well as its own version) at runtime. I also need to be able to update the version number(s) from a script, not by hand.

I need a solution that works on linux, but I'd prefer for it to also work on Windows.

One thing I've thought about is having a "version" file at the top level of each repo (one git repo per target) containing nothing more than the version number, and using the "xxd -i version version.h" command to generate a static array I can compile into my code. However, this fails the "works on Windows" test, among other things.

Any suggestions?