Skip to content

Commit

Permalink
Provide a numeric version number to compare against. (#1054)
Browse files Browse the repository at this point in the history
Including simple example in version.h.in and checking
in the test-{cmake,pkgconfig}.sh scripts.
  • Loading branch information
hzeller authored Nov 18, 2024
1 parent 7f298aa commit 182adae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cmake/version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion scripts/test-cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ EOT
cat <<EOT > test.cpp
#include <manifold/manifold.h>
#include <manifold/version.h>
#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

Expand All @@ -21,4 +26,3 @@ cd build
cmake ..
make
./testing

5 changes: 5 additions & 0 deletions scripts/test-pkgconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ EOT
cat <<EOT > testing.cpp
#include <manifold/manifold.h>
#include <manifold/version.h>
#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

Expand Down

0 comments on commit 182adae

Please sign in to comment.