]> granicus.if.org Git - libjpeg-turbo/commitdiff
Build: Add integer version macro to jconfig.h
authorDRC <information@libjpeg-turbo.org>
Wed, 11 May 2016 00:36:34 +0000 (19:36 -0500)
committerDRC <information@libjpeg-turbo.org>
Wed, 11 May 2016 00:36:52 +0000 (19:36 -0500)
This makes it significantly easier to do conditional compilation based
on the libjpeg-turbo version.

Based on:
https://github.com/hasinoff/libjpeg-turbo/commit/e6d5b3e50b8b07488cb7b4d26ab2061685bc6875
https://github.com/hasinoff/libjpeg-turbo/commit/1394a89ba6f3cd8abb556c1b65bac4a5f09760d0

Closes #80

CMakeLists.txt
configure.ac
jconfig.h.in
win/jconfig.h.in

index 1ad29f06e6691b98455e4804ca837da7234e6f72..5924f0cfbc228e68ebfafd6c270239fc55e269d9 100644 (file)
@@ -10,6 +10,24 @@ endif()
 
 project(libjpeg-turbo C)
 set(VERSION 1.4.90)
+string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
+list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
+list(GET VERSION_TRIPLET 1 VERSION_MINOR)
+list(GET VERSION_TRIPLET 2 VERSION_REVISION)
+function(pad_number NUMBER OUTPUT_LEN)
+  string(LENGTH "${${NUMBER}}" INPUT_LEN)
+  if(INPUT_LEN LESS OUTPUT_LEN)
+    math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
+    set(NUM ${${NUMBER}})
+    foreach(C RANGE ${ZEROES})
+      set(NUM "0${NUM}")
+    endforeach()
+    set(${NUMBER} ${NUM} PARENT_SCOPE)
+  endif()
+endfunction()
+pad_number(VERSION_MINOR 3)
+pad_number(VERSION_REVISION 3)
+set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
 
 if(NOT WIN32)
   message(FATAL_ERROR "Platform not supported by this build system.  Use autotools instead.")
index 9b2c573cc2e2bb4b70417f9a9c393027005f8ae9..c728ee8191ae582205fe90e9397b5d41339cfd13 100644 (file)
@@ -224,6 +224,16 @@ AC_SUBST(MEM_SRCDST_FUNCTIONS)
 
 AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION, [$VERSION], [libjpeg-turbo version])
 
+m4_define(version_triplet,m4_split(AC_PACKAGE_VERSION,[[.]]))
+m4_define(version_major,m4_argn(1,version_triplet))
+m4_define(version_minor,m4_argn(2,version_triplet))
+m4_define(version_revision,m4_argn(3,version_triplet))
+VERSION_MAJOR=version_major
+VERSION_MINOR=version_minor
+VERSION_REVISION=version_revision
+LIBJPEG_TURBO_VERSION_NUMBER=`printf "%d%03d%03d" $VERSION_MAJOR $VERSION_MINOR $VERSION_REVISION`
+AC_DEFINE_UNQUOTED(LIBJPEG_TURBO_VERSION_NUMBER, [$LIBJPEG_TURBO_VERSION_NUMBER], [libjpeg-turbo version in integer form])
+
 VERSION_SCRIPT=yes
 AC_ARG_ENABLE([ld-version-script],
   AS_HELP_STRING([--disable-ld-version-script],
index 42d86f244373adde9708dd392ae7c657a5301a99..02c12cc13b19f4a864cde37f19b79e2f08c3d2dd 100644 (file)
@@ -6,6 +6,9 @@
 /* libjpeg-turbo version */
 #define LIBJPEG_TURBO_VERSION 0
 
+/* libjpeg-turbo version in integer form */
+#define LIBJPEG_TURBO_VERSION_NUMBER 0
+
 /* Support arithmetic encoding */
 #undef C_ARITH_CODING_SUPPORTED
 
index 8783900ee9637877da9f49bc8eff3c974218f8e2..9d35121e8d37df8e9f01cfed89015b220cc8573c 100644 (file)
@@ -3,6 +3,7 @@
 
 #define JPEG_LIB_VERSION @JPEG_LIB_VERSION@
 #define LIBJPEG_TURBO_VERSION @VERSION@
+#define LIBJPEG_TURBO_VERSION_NUMBER @LIBJPEG_TURBO_VERSION_NUMBER@
 #cmakedefine C_ARITH_CODING_SUPPORTED
 #cmakedefine D_ARITH_CODING_SUPPORTED
 #cmakedefine MEM_SRCDST_SUPPORTED