Get version string from git-describe, git-archive or CMake config
Currently if the source directory is not a git repo, the version string will be the last released version set in the ICINGA2_VERSION file.
This PR makes the following improvements:
- If
git-describefails because the source directory isn't a git repo orICINGA2_GIT_VERSION_INFOis OFF, the version is read from a file processed bygit-archive. - The version file
ICINGA2_VERSIONis removed and replaced with a variable at the top of the main CMakeLists.txt that will need to be updated manually on a new release. - New variables
ICINGA2_PACKAGE_(VERSION|REVISION|VENDOR)are added that can be customized by package build process. These are utilized for Windows MSI builds (via CPACK) - Package version information can be printed in
icinga2 --versionif the new optionICINGA2_INCLUDE_PACKAGE_INFOis set to ON (defaults to OFF). I added an additional option for this because I wanted to use defaults, description and type for the package version/revision/vendor cache variables, and otherwise there is no reliable way to detect that the user has changed the information and include the--versionsection based on that.
Here is an overview of how the variables/constants and their meaning has changed:
Before:
| CMake | C++ (and Windows cruft) | meaning |
|---|---|---|
| GIT_VERSION | VERSION | The best approximation of the actual version, either git describe or spec version + revision from the ICINGA2_VERSION file |
| ICINGA2_VERSION | ICINGA2_VERSION | Like above with the 'v' prefix removed and no package revision suffix in case no git version was found |
| SPEC_VERSION | SPEC_VERSION | The package version defined manually in the ICINGA2_VERSION file |
After:
| CMake | C++ (and Windows cruft) | meaning |
|---|---|---|
| ICINGA2_VERSION | ICINGA_VERSION | The best approximation of the actual version, going from git-describe -> git-archive info -> package version + revision |
| ICINGA2_RC_VERSION | ICINGA_RC_VERSION | Like above, but with removed 'v' prefix |
| ICINGA2_PACKAGE_VERSION | ICINGA_PACKAGE_VERSION | The manually defined, abbreviated version string |
Fixes #10016 Fixes #8960
You found a thing here that I wasn't really aware of so far:
GetAppSpecVersion(). It looks like you started using that new package version thing where this was used before, can you summarize why you did it that way?
Firstly, the icinga.rc file using the PACKAGE_VERSION constant was a misunderstanding from me, because I didn't see that it could also use the full git version, just with the 'v' removed.
Mostly I tried to get some consistency into what the variables mean. SPEC_VERSION is replaced with ICINGA_PACKAGE_VERSION and ICINGA2_VERSION (which previously was just a copy of SPEC_VERSION) is now the "real" version, that only defaults to the package version if all other means of getting a version string fail.
I'll update the PR description with a comparison between master and this PR.