From 48b4e0bf6f1cc4ce4831c2212d57f00fe792468f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 20 Jul 2016 12:44:16 +0200 Subject: Improve library version handling Output the version as a define into the private config header as a define using a hex number. Like that we can easily do version checks on libraries using the QT_LIBRARY_VERSION(lib) and QT_VERSION_CHECK() macros. Change-Id: I6dc4ac6550886ca95c5542b6e75cd933ed079d76 Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_configure.prf | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'mkspecs/features/qt_configure.prf') diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 880d71fab1..7d5814e4b1 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -515,6 +515,18 @@ defineReplace(qtConfLibraryArgs) { return($$qmake_args) } +defineReplace(qtConfGetHexVersion) { + version = $$split(1, '.') + number = + for(i, 0..2) { + n = $$member(version, $$i) + isEmpty(n): n = 0 + number += $$format_number($$n, obase=16 zeropad width=2) + } + number = "0x$$join(number)" + return($$number) +} + defineTest(qtConfExportLibrary) { isEmpty(2): return() !$$qtConfEvaluate($$eval($${1}.export)): return() @@ -524,7 +536,7 @@ defineTest(qtConfExportLibrary) { eval(libs = $$eval($${1}.libs)) eval(cflags = $$eval($${1}.cflags)) eval(includes = $$eval($${1}.includedir)) - version = $$split($${1}.version, '.') + version = $$eval($${1}.version) NAME = $$upper($$2) !isEmpty(libs): qtConfOutputVar(assign, $$output, QMAKE_LIBS_$$NAME, $$libs) @@ -534,6 +546,9 @@ defineTest(qtConfExportLibrary) { !isEmpty(cflags): qtConfOutputVar(assign, $$output, QMAKE_CFLAGS_$$NAME, $$cflags) !isEmpty(includes): qtConfOutputVar(assign, $$output, QMAKE_INCDIR_$$NAME, $$includes) !isEmpty(version) { + qtConfOutputVar(assign, $$output, QMAKE_$${NAME}_VERSION, $$version) + qtConfOutputSetDefine("privateHeader", "QT_LIBRARY_VERSION_$${2}", $$qtConfGetHexVersion($$version)) + version = $$split(version, '.') qtConfOutputVar(assign, $$output, QMAKE_$${NAME}_VERSION_MAJOR, $$member(version, 0)) qtConfOutputVar(assign, $$output, QMAKE_$${NAME}_VERSION_MINOR, $$member(version, 1)) qtConfOutputVar(assign, $$output, QMAKE_$${NAME}_VERSION_PATCH, $$member(version, 2)) -- cgit v1.2.3