Skip to content

Commit

Permalink
Update version files to support intermediate version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
GarrettDMorrison committed Mar 29, 2022
1 parent 15d7717 commit dd915b9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 20 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ string(REGEX REPLACE ".*#define[ \t]+ZFP_VERSION_MINOR[ \t]+([0-9]+).*"
"\\1" ZFP_VERSION_MINOR ${_zfp_h_contents})
string(REGEX REPLACE ".*#define[ \t]+ZFP_VERSION_PATCH[ \t]+([0-9]+).*"
"\\1" ZFP_VERSION_PATCH ${_zfp_h_contents})
set(ZFP_VERSION
"${ZFP_VERSION_MAJOR}.${ZFP_VERSION_MINOR}.${ZFP_VERSION_PATCH}")
string(REGEX REPLACE ".*#define[ \t]+ZFP_VERSION_TWEAK[ \t]+([0-9]+).*"
"\\1" ZFP_VERSION_TWEAK ${_zfp_h_contents})

if(${ZFP_VERSION_TWEAK} EQUAL 0)
set(ZFP_VERSION
"${ZFP_VERSION_MAJOR}.${ZFP_VERSION_MINOR}.${ZFP_VERSION_PATCH}")
else()
set(ZFP_VERSION
"${ZFP_VERSION_MAJOR}.${ZFP_VERSION_MINOR}.${ZFP_VERSION_PATCH}.${ZFP_VERSION_TWEAK}")
endif()

project(ZFP VERSION ${ZFP_VERSION})

Expand Down
27 changes: 25 additions & 2 deletions docs/source/high-level-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ Macros
.. c:macro:: ZFP_VERSION_MAJOR
.. c:macro:: ZFP_VERSION_MINOR
.. c:macro:: ZFP_VERSION_PATCH
.. c:macro:: ZFP_VERSION_TWEAK
.. c:macro:: ZFP_VERSION
.. c:macro:: ZFP_VERSION_STRING
Macros identifying the |zfp| library version. :c:macro:`ZFP_VERSION` is
a single integer constructed from the previous three macros
a single integer constructed from the previous four macros
(see :c:macro:`ZFP_MAKE_VERSION`). :c:macro:`ZFP_VERSION_STRING` is a
string literal (see :c:macro:`ZFP_MAKE_VERSION_STRING`). See also
:c:data:`zfp_library_version` and :c:data:`zfp_version_string`.
:c:data:`zfp_library_version` and :c:data:`zfp_version_string`.
:c:macro:`ZFP_VERSION_TWEAK` is new as of |zfp| |versionrelease| and used
to mark intermediate develop versions.

----

Expand All @@ -59,13 +62,33 @@ Macros

----

.. c:macro:: ZFP_MAKE_FULLVERSION(major, minor, patch, tweak)
.. c:macro:: ZFP_MAKE_FULLVERSION_STRING(major, minor, patch, tweak)
Utility macros for constructing :c:macro:`ZFP_VERSION` and
:c:macro:`ZFP_VERSION_STRING`, respectively. Includes tweak version
used by intermediate develop versions. Available as of
|zfp| |versionrelease|, these macros may be used by applications to test
for a certain |zfp| version number, e.g.,
:code:`#if ZFP_VERSION >= ZFP_MAKE_FULLVERSION(0, 5, 6, 1)`.

----

.. c:macro:: ZFP_CODEC
Macro identifying the version of the compression CODEC. See also
:c:data:`zfp_codec_version`.

----

.. c:macro:: ZFP_DEVELOP
Macro identifying that the current version is an intermediate develop
version as opposed to an official release. Available as of |zfp|
|versionrelease|.

----

.. c:macro:: ZFP_MIN_BITS
.. c:macro:: ZFP_MAX_BITS
.. c:macro:: ZFP_MAX_PREC
Expand Down
65 changes: 49 additions & 16 deletions include/zfp/version.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,70 @@
#ifndef ZFP_VERSION_H
#define ZFP_VERSION_H

/* library version information */
#define ZFP_VERSION_MAJOR 0 /* library major version number */
#define ZFP_VERSION_MINOR 5 /* library minor version number */
#define ZFP_VERSION_PATCH 5 /* library patch version number */
#define ZFP_VERSION_TWEAK 0 /* library tweak version number */

#define ZFP_VERSION_RELEASE ZFP_VERSION_MAJOR

/* codec version number (see also zfp_codec_version) */
#define ZFP_CODEC 5

/* whether this is a full release or intermediate version */
#define ZFP_DEVELOP 1

/* stringification */
#define _zfp_str_(x) # x
#define _zfp_str(x) _zfp_str_(x)

/* macro for generating an integer version identifier */
#define ZFP_MAKE_VERSION(major, minor, patch) \
(((major) << 8) + \
((minor) << 4) + \
((patch) << 0))
#define ZFP_MAKE_VERSION(major, minor, patch, tweak) \
(((major) << 12) + \
((minor) << 8) + \
((patch) << 4) + \
((tweak) << 0))

/* macro for generating a version string */
/* macros for generating a version string */
#define ZFP_MAKE_VERSION_STRING(major, minor, patch) \
_zfp_str(major) "." \
_zfp_str(minor) "." \
_zfp_str(patch)

/* library version information */
#define ZFP_VERSION_MAJOR 0 /* library major version number */
#define ZFP_VERSION_MINOR 5 /* library minor version number */
#define ZFP_VERSION_PATCH 5 /* library patch version number */
#define ZFP_VERSION_RELEASE ZFP_VERSION_PATCH
#define ZFP_MAKE_VERSION_STRING(major, minor, patch) \
_zfp_str(major) "." \
_zfp_str(minor) "." \
_zfp_str(patch)

/* codec version number (see also zfp_codec_version) */
#define ZFP_CODEC 5
#define ZFP_MAKE_FULLVERSION_STRING(major, minor, patch, tweak) \
_zfp_str(major) "." \
_zfp_str(minor) "." \
_zfp_str(patch) "." \
_zfp_str(tweak)

#define ZFP_MAKE_FULLVERSION_STRING(major, minor, patch, tweak) \
_zfp_str(major) "." \
_zfp_str(minor) "." \
_zfp_str(patch) "." \
_zfp_str(tweak)

/* library version number (see also zfp_library_version) */
#define ZFP_VERSION \
ZFP_MAKE_VERSION(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH)
#if ZFP_VERSION_TWEAK == 0
#define ZFP_VERSION \
ZFP_MAKE_VERSION(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH)
#else
#define ZFP_VERSION \
ZFP_MAKE_FULLVERSION(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH, ZFP_VERSION_TWEAK)
#endif

/* library version string (see also zfp_version_string) */
#define ZFP_VERSION_STRING \
ZFP_MAKE_VERSION_STRING(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH)
#if ZFP_VERSION_TWEAK == 0
#define ZFP_VERSION_STRING \
ZFP_MAKE_VERSION_STRING(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH)
#else
#define ZFP_VERSION_STRING \
ZFP_MAKE_FULLVERSION_STRING(ZFP_VERSION_MAJOR, ZFP_VERSION_MINOR, ZFP_VERSION_PATCH, ZFP_VERSION_TWEAK)
#endif

#endif
2 changes: 2 additions & 0 deletions zfp-config-version.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(PACKAGE_VERSION_MAJOR @ZFP_VERSION_MAJOR@)
set(PACKAGE_VERSION_MINOR @ZFP_VERSION_MINOR@)
set(PACKAGE_VERSION_PATCH @ZFP_VERSION_PATCH@)
set(PACKAGE_VERSION_TWEAK @ZFP_VERSION_TWEAK@)

set(PACKAGE_VERSION @ZFP_VERSION@)

# Check whether the requested PACKAGE_FIND_VERSION is compatible
Expand Down

0 comments on commit dd915b9

Please sign in to comment.