Ideally I would like to write the version number of my project only in one place, and have it accessed/propagated throughout the whole build process, on Mac and Windows.
By that, I mean that I want the version number available not only at the level of C++ code (for that, a simple #define would be enough), but also for the pre and post build scripts executed by Xcode and Visual Studio.
Perhaps Projucer --set-version or Projucer --get-version could help? I use the latter all the time in post build scripts to name installer & zip files. If I could somehow inject my version number into my Inno Setup project file on Windows, though, then I would localize my version string to a single file.
For the current git commit sha, I use echo '"'$(git rev-parse HEAD)'"' > ${PROJECT_DIR}/GitCommitSha.h as an Xcode pre-build script so that I can inject it into my logging code. I’m guessing the same could be done for simple text file that contains the one and only version string as a single line. For Windows it’s a bit more wordy:
@echo off
del /q GitCommitSha.h
for /f %%i in ('git rev-parse HEAD') do set currSha=%%i
echo updating git commit sha header to %currSha%
echo "%currSha%" > GitCommitSha.h
I’m not using Projucer so the --set-version and --get-version options are not a feasible solution.
I resorted to using a single xcconfig file on macOS and a single property sheet on Windows.
In both cases, the custom macros can both be used as preprocessor macros during compilation, and propagated as environment variables for the pre and post build scripts. Works for me.
@tadnicol, as for propagating your version number to InnoSetup, you could echo the version emitted by Projucer --get-version to a .h file, and then #include it in your InnoSetup script. InnoSetup offers a preprocessor which allows you to do that.
I’m not using any meta-project generator/manager because this is an old project that was born before Projucer (then Introjucer) even existed, nor I have looked for alternatives to it honestly.