Added --version option

This commit is contained in:
Joel Holdsworth 2012-10-13 00:59:37 +01:00 committed by Uwe Hermann
parent cef18fc616
commit f7951df4a1
3 changed files with 29 additions and 1 deletions

View File

@ -58,6 +58,8 @@ find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
#= Config Header
#-------------------------------------------------------------------------------
set(PV_TITLE PulseView)
set(PV_VERSION_MAJOR 0)
set(PV_VERSION_MINOR 1)
set(PV_VERSION_MICRO 0)
@ -186,7 +188,9 @@ install(PROGRAMS pulseview DESTINATION bin/)
if(ENABLE_TESTS)
add_definitions(-DBOOST_TEST_DYN_LINK)
add_definitions(pulseview-tests
-DBOOST_TEST_DYN_LINK
)
add_executable(pulseview-test
${pulseview_TEST_SOURCES}

View File

@ -20,6 +20,9 @@
#ifndef _PULSEVIEW_CONFIG_H
#define _PULSEVIEW_CONFIG_H
/* Application Details */
#define PV_TITLE "@PV_TITLE@"
/* Pulseview version information */
#define PV_VERSION_MAJOR @PV_VERSION_MAJOR@
#define PV_VERSION_MINOR @PV_VERSION_MINOR@

View File

@ -24,6 +24,8 @@ extern "C" {
#include <libsigrok/libsigrok.h>
}
#include <getopt.h>
#include <QtGui/QApplication>
#include <QDebug>
@ -40,6 +42,25 @@ int main(int argc, char *argv[])
QApplication::setApplicationName("PulseView");
QApplication::setOrganizationDomain("http://www.sigrok.org");
// Parse arguments
while (1) {
static const struct option long_options[] = {
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0}
};
const char c = getopt_long(argc, argv, "V", long_options, NULL);
if (c == -1)
break;
switch (c) {
case 'V':
// Print version info
fprintf(stderr, "%s %s\n", PV_TITLE, PV_VERSION_STRING);
return 0;
}
}
// Initialise libsigrok
if (sr_init() != SR_OK) {
qDebug() << "ERROR: libsigrok init failed.";