GH-808: Add ZEEK_VERSION_NUMBER definition to zeek-config.h

This is the result of (major * 10000 + minor * 100 + patch), for example
3.1.2 becomes 30102.  This definition may be helpful for external code
that requires conditional compilation to support multiple Zeek
versions with differing APIs.
This commit is contained in:
Jon Siwek 2020-02-21 12:34:46 -08:00 committed by Robin Sommer
parent bf212b2d3c
commit 48fba11c51
2 changed files with 9 additions and 1 deletions

View file

@ -79,11 +79,14 @@ execute_process(COMMAND grep "^#define *BRO_PLUGIN_API_VERSION"
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "^#define.*VERSION *" "" API_VERSION "${API_VERSION}")
string(REPLACE "." " " version_numbers ${VERSION})
string(REGEX REPLACE "[.-]" " " version_numbers ${VERSION})
separate_arguments(version_numbers)
list(GET version_numbers 0 VERSION_MAJOR)
list(GET version_numbers 1 VERSION_MINOR)
list(GET version_numbers 2 VERSION_PATCH)
set(VERSION_MAJ_MIN "${VERSION_MAJOR}.${VERSION_MINOR}")
math(EXPR ZEEK_VERSION_NUMBER
"${VERSION_MAJOR} * 10000 + ${VERSION_MINOR} * 100 + ${VERSION_PATCH}")
set(VERSION_C_IDENT "${VERSION}_plugin_${API_VERSION}")
string(REGEX REPLACE "-[0-9]*$" "_git" VERSION_C_IDENT "${VERSION_C_IDENT}")

View file

@ -131,6 +131,11 @@
/* Version number of package */
#define VERSION "@VERSION@"
// Zeek version number.
// This is the result of (major * 10000 + minor * 100 + patch)
// For example, 3.1.2 becomes 30102.
#define ZEEK_VERSION_NUMBER @ZEEK_VERSION_NUMBER@
/* whether words are stored with the most significant byte first */
#cmakedefine WORDS_BIGENDIAN