From cf15841bba3ccf99174dd776ecd5bba51aa35d88 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Thu, 21 Jun 2018 11:13:24 +0200 Subject: Add version.cc generation to qmake build To generate the version.cc file with the correct version information, this patch introduces new variables VERSION_MAJOR, VERSION_MINOR and VERSION_GIT with the required information and then defines a custom compiler that calls sed to replace the placeholders in version.cc.in and to create version.cc. --- libnitrokey.pro | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libnitrokey.pro b/libnitrokey.pro index ea86294..5752764 100644 --- a/libnitrokey.pro +++ b/libnitrokey.pro @@ -7,7 +7,10 @@ CONFIG += c++14 shared debug TEMPLATE = lib TARGET = nitrokey -VERSION = 3.3 +VERSION_MAJOR = 3 +VERSION_MINOR = 3 +VERSION_GIT = $$system(git describe --always) +VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR} QMAKE_TARGET_COMPANY = Nitrokey QMAKE_TARGET_PRODUCT = libnitrokey QMAKE_TARGET_DESCRIPTION = Communicate with Nitrokey stick devices in a clean and easy manner @@ -44,6 +47,19 @@ SOURCES = \ $$PWD/NK_C_API.cc +VERSION_SOURCES = $$PWD/version.cc.in + + +sed_version.output = ${QMAKE_FILE_BASE} +sed_version.commands = cat ${QMAKE_FILE_NAME} \ + | sed 's/@PROJECT_VERSION_MAJOR@/$${VERSION_MAJOR}/' \ + | sed 's/@PROJECT_VERSION_MINOR@/$${VERSION_MINOR}/' \ + | sed 's/@PROJECT_VERSION_GIT@/$${VERSION_GIT}/' \ + > ${QMAKE_FILE_OUT} +sed_version.input = VERSION_SOURCES +sed_version.variable_out = SOURCES +QMAKE_EXTRA_COMPILERS += sed_version + tests { SOURCES += \ $$PWD/unittest/catch_main.cpp \ @@ -54,6 +70,7 @@ tests { $$PWD/unittest/test_HOTP.cc } + unix:!macx{ # SOURCES += $$PWD/hidapi/linux/hid.c LIBS += -lhidapi-libusb -- cgit v1.2.3