Freshen version number when building with CMake

Fixes #979
This commit is contained in:
ISSOtm
2022-03-10 19:36:05 +01:00
committed by Eldred Habert
parent da66eeb40e
commit a4ead0c25f
4 changed files with 22 additions and 7 deletions

2
src/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Generated by CMake
/.version.c

View File

@@ -6,10 +6,12 @@
# SPDX-License-Identifier: MIT
#
configure_file(version.c _version.c ESCAPE_QUOTES)
set(common_src
"error.c"
"extern/getopt.c"
"version.c"
"_version.c"
)
find_package(PkgConfig)

View File

@@ -12,6 +12,13 @@
#include "helpers.h"
#include "version.h"
// This variable is passed via `-D` from the Makefile, but not from CMake
// (in which `configure_file()` is used on this file to replace some syntax)
#ifndef BUILD_VERSION_STRING
// CMake-specific syntax here
#define BUILD_VERSION_STRING "@GIT_REV@"
#endif
char const *get_package_version_string(void)
{
// The following conditional should be simplified by the compiler.