Skip to content

Commit

Permalink
Build: Add integer version macro to jconfig.h
Browse files Browse the repository at this point in the history
This makes it significantly easier to do conditional compilation based
on the libjpeg-turbo version.

Based on:
hasinoff@e6d5b3e
hasinoff@1394a89

Closes libjpeg-turbo#80
  • Loading branch information
dcommander committed May 11, 2016
1 parent 5c064de commit f06cc12
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
3 changes: 3 additions & 0 deletions jconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions win/jconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f06cc12

Please sign in to comment.