diff --git a/CMakeLists.txt b/CMakeLists.txt index 24ba7d657..ca5df5eb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 1500a1f70..d006baa3f 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -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. ---- @@ -59,6 +62,18 @@ 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 @@ -66,6 +81,14 @@ Macros ---- +.. 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 diff --git a/include/zfp/version.h b/include/zfp/version.h index 294cc151e..8a428614f 100644 --- a/include/zfp/version.h +++ b/include/zfp/version.h @@ -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 diff --git a/zfp-config-version.cmake.in b/zfp-config-version.cmake.in index 4a77db0a1..449327023 100644 --- a/zfp-config-version.cmake.in +++ b/zfp-config-version.cmake.in @@ -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