add command line option to show version

This commit is contained in:
Jussi Kuokkanen
2023-11-05 15:42:15 +02:00
parent 743473711a
commit d34df838e6
5 changed files with 21 additions and 3 deletions

View File

@@ -1,4 +1,9 @@
# Define libtuxclocker target here since others depend on it
# Version information
tuxclocker_version = '1.3.0-rc.1'
git_commit = run_command('git', 'describe', '--always', '--dirty').stdout().strip()
version_string = '@0@, git commit @1@'.format(tuxclocker_version, git_commit)
# Used in preprocessor
version_string_def = '-DTUXCLOCKER_VERSION_STRING="@0@"'.format(version_string)
# OpenSSL is used for hash functions
openssl_dep = dependency('openssl')
@@ -15,6 +20,7 @@ plugin_path_def = plugin_path_def_template.format(get_option('prefix'), get_opti
locale_path_def_template = '-DTUXCLOCKER_LOCALE_PATH="@0@/@1@/locale"'
locale_path_def = locale_path_def_template.format(get_option('prefix'), get_option('datadir'))
# Define libtuxclocker target here since others depend on it
libtuxclocker = shared_library('tuxclocker',
['lib/Crypto.cpp',
'lib/Plugin.cpp'],

View File

@@ -1,10 +1,16 @@
#include <libintl.h>
#include <QApplication>
#include <QCommandLineParser>
#include "MainWindow.hpp"
int main(int argc, char **argv) {
QApplication app(argc, argv);
app.setApplicationVersion(TUXCLOCKER_VERSION_STRING);
QCommandLineParser parser;
parser.addVersionOption();
parser.process(app);
setlocale(LC_MESSAGES, "");
bindtextdomain("tuxclocker", TUXCLOCKER_LOCALE_PATH);

View File

@@ -46,5 +46,5 @@ executable('tuxclocker-qt',
override_options : ['cpp_std=c++17'],
dependencies: qt5_dep,
include_directories: [incdir, local_incdir],
cpp_args : locale_path_def,
cpp_args : [locale_path_def, version_string_def],
install: true)

View File

@@ -1,6 +1,7 @@
#include <DBusTypes.hpp>
#include <iostream>
#include <libintl.h>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusError>
@@ -21,6 +22,11 @@ namespace TCDBus = TuxClocker::DBus;
int main(int argc, char **argv) {
QCoreApplication a(argc, argv);
a.setApplicationVersion(TUXCLOCKER_VERSION_STRING);
QCommandLineParser parser;
parser.addVersionOption();
parser.process(a);
// TODO: should numbers here be localized or not?
setlocale(LC_MESSAGES, "");

View File

@@ -18,7 +18,7 @@ executable('tuxclockerd',
include_directories : [incdir, patterns_inc],
dependencies : [qt5_dep, boost_dep],
link_with : libtuxclocker,
cpp_args : locale_path_def,
cpp_args : [locale_path_def, version_string_def],
install : true)
# DBus data directories