aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2018-06-21 11:13:24 +0200
committerRobin Krahl <me@robin-krahl.de>2018-06-21 11:15:26 +0200
commitcf15841bba3ccf99174dd776ecd5bba51aa35d88 (patch)
tree48bd17a55a70195617eb4f7e77f79fc5a39f8d26
parente1ef8d79809190c5ac5d540bd4aa376dcfda7e93 (diff)
downloadlibnitrokey-qmake-version.tar.gz
libnitrokey-qmake-version.tar.bz2
Add version.cc generation to qmake buildqmake-version
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.
-rw-r--r--libnitrokey.pro19
1 files changed, 18 insertions, 1 deletions
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