feat: support Qt application version attribute

Automatically pick up on the CMake project version and forward it to the applicationVersion attribute of Qt.
master
Johan Ouwerkerk 2020-10-02 20:59:13 +02:00
parent d7f850a146
commit d7c8eb4be4
4 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
.flatpak-builder/*
/build*/
AndroidManifest.xml
/src/version.h

View File

@ -16,6 +16,8 @@ add_subdirectory(model)
add_subdirectory(validators)
add_subdirectory(app)
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")
set(keysmith_SRCS
main.cpp
)

View File

@ -22,6 +22,8 @@
#include "validators/issuervalidator.h"
#include "validators/secretvalidator.h"
#include "version.h"
/*
* Integrate QML debugging/profiling support, conditional on building Keysmith in Debug mode.
* NDEBUG is defined by the C standard and automatically set by CMake during a Release type build, hence the double negative.
@ -40,6 +42,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
QCoreApplication::setApplicationName(QStringLiteral("Keysmith"));
QCoreApplication::setApplicationVersion(KEYSMITH_VERSION_STRING);
QGuiApplication::setApplicationDisplayName(i18nc("@title", "Keysmith"));
QCommandLineParser cliParser;

12
src/version.h.in Normal file
View File

@ -0,0 +1,12 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2020 Johan Ouwerkerk <jm.ouwerkerk@gmail.com>
*/
#ifndef KEYSMITH_VERSION_H
#define KEYSMITH_VERSION_H
#include <QString>
#define KEYSMITH_VERSION_STRING (QStringLiteral("@keysmith_VERSION@"))
#endif