diff --git a/cmake/version.h.in b/cmake/version.h.in index f708f90c9..c9a0b0ea6 100644 --- a/cmake/version.h.in +++ b/cmake/version.h.in @@ -17,3 +17,13 @@ #define MANIFOLD_VERSION_MAJOR @MANIFOLD_VERSION_MAJOR@ #define MANIFOLD_VERSION_MINOR @MANIFOLD_VERSION_MINOR@ #define MANIFOLD_VERSION_PATCH @MANIFOLD_VERSION_PATCH@ + +// Comparable version numbers to check version in code or preprocessing. +// Check if your minimum requirements are met with e.g. +// MANIFOLD_VERSION > MANIFOLD_VERSION_NUMBER(2, 5, 1) +#define MANIFOLD_VERSION_NUMBER(v_major, v_minor, v_patch) \ + (((v_major) * 1000000) + ((v_minor) * 1000) + (v_patch)) + +#define MANIFOLD_VERSION MANIFOLD_VERSION_NUMBER(MANIFOLD_VERSION_MAJOR, \ + MANIFOLD_VERSION_MINOR, \ + MANIFOLD_VERSION_PATCH) diff --git a/scripts/test-cmake.sh b/scripts/test-cmake.sh index 456632cb2..282b08061 100755 --- a/scripts/test-cmake.sh +++ b/scripts/test-cmake.sh @@ -13,6 +13,11 @@ EOT cat < test.cpp #include #include + +#if MANIFOLD_VERSION < MANIFOLD_VERSION_NUMBER(2, 5, 1) +# error "Unexpected: minimum version number not available" +#endif + int main() { manifold::Manifold foo; return 0; } EOT @@ -21,4 +26,3 @@ cd build cmake .. make ./testing - diff --git a/scripts/test-pkgconfig.sh b/scripts/test-pkgconfig.sh index e3f7ccd29..8e518bcda 100755 --- a/scripts/test-pkgconfig.sh +++ b/scripts/test-pkgconfig.sh @@ -12,6 +12,11 @@ EOT cat < testing.cpp #include #include + +#if MANIFOLD_VERSION < MANIFOLD_VERSION_NUMBER(2, 5, 1) +# error "Unexpected: minimum version number not available" +#endif + int main() { manifold::Manifold foo; return 0; } EOT