skaravos / CMakeVersionInfoTarget

CMake - VersionInfoTarget
MIT License
0 stars 1 forks source link

Change `VersionSummary` variable to shell variable format #2

Closed skaravos closed 2 months ago

skaravos commented 2 months ago

Perhaps the generated VersionSummary variable should be formatted with = signs instead of :

Right now it prints like this:

Project: Test_CMakeVersionInfoTarget_Lang_C
Version: 1.2.3.4
Compiler: MSVC-19.39.33519.0
Platform: AMD64-Debug
CommitHash: 3898f357430934cb9a1dea5f85832304ee302137 (uncommitted changes)
CommitUser: Stephen Karavos (skaravos@outlook.com)
CommitDate: Tue Nov 29 03:42:27 2022 -0400

But perhaps it could be like this?

Project=Test_CMakeVersionInfoTarget_Lang_C
Version=1.2.3.4
Compiler=MSVC-19.39.33519.0
Platform=AMD64-Debug
RepoHadUncommittedChanges=yes
CommitHash=3898f357430934cb9a1dea5f85832304ee302137
CommitUserName=Stephen Karavos
CommitUserEmail=skaravos@outlook.com
CommitDate=Tue Nov 29 03:42:27 2022 -0400

This output could be sourced or run directly inside a POSIX shell to acquire usable shell variables from a binary by running it with --version.

. <(./FooCXX --version)  # 'source' the version output of the program
echo $CommitHash
echo $Project
echo $Version

> 3898f357430934cb9a1dea5f85832304ee302137
> Test_CMakeVersionInfoTarget_Lang_C
> 1.2.3.4

Maybe changing the value of the generated VersionSummary variable isn't wise, but instead adding a second generated variable like VersionSummaryFull that contains all the version info in the VAR=VAL format?