Generate a config.h file for versioning
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>
Fri, 12 Oct 2012 20:38:06 +0000 (15:38 -0500)
committerUwe Hermann <uwe@hermann-uwe.de>
Sat, 13 Oct 2012 13:02:44 +0000 (15:02 +0200)
Versioning was already handled in CMakeLists.txt, but it was handled
in a non-standard and unclear manner. We used
    set(VERSION
for starters. While this is valid CMake syntax, VERSION is also a
reserved word in cmake, depending on the context. We were
communicating the version information by a compile-time define, again,
not a recommended practice.

Change versioning to the more standard way of
    set(*VERSION_MAJOR
    set(*VERSION_MINOR
    set(*VERSION_MICRO
    set(*VERSION_STRING

Instead of defining the version at compile time, generate a config.h
file with the version information.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
CMakeLists.txt
config.h.in [new file with mode: 0644]
main.cpp

index 60d7bfacfb37000059e9e2602611c449b5275fbe..2448a32f3e00229897925fac339ef90bfe479586 100644 (file)
@@ -54,7 +54,21 @@ endif(WIN32)
 find_package(Qt4 REQUIRED)
 find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
 
-set(VERSION 0.1.0)
+#===============================================================================
+#= Config Header
+#-------------------------------------------------------------------------------
+
+set(PV_VERSION_MAJOR 0)
+set(PV_VERSION_MINOR 1)
+set(PV_VERSION_MICRO 0)
+set(PV_VERSION_STRING
+       ${PV_VERSION_MAJOR}.${PV_VERSION_MINOR}.${PV_VERSION_MICRO}
+)
+
+configure_file (
+       ${PROJECT_SOURCE_DIR}/config.h.in
+       ${PROJECT_BINARY_DIR}/config.h
+)
 
 #===============================================================================
 #= Sources
@@ -115,7 +129,6 @@ include(${QT_USE_FILE})
 #-------------------------------------------------------------------------------
 
 add_definitions(${QT_DEFINITIONS})
-add_definitions(-DAPP_VERSION="${VERSION}")
 
 #===============================================================================
 #= Global Include Directories
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..ea9b0d4
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * This file is part of pulseview.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _PULSEVIEW_CONFIG_H
+#define _PULSEVIEW_CONFIG_H
+
+/* Pulseview version information */
+#define PV_VERSION_MAJOR @PV_VERSION_MAJOR@
+#define PV_VERSION_MINOR @PV_VERSION_MINOR@
+#define PV_VERSION_MICRO @PV_VERSION_MICRO@
+#define PV_VERSION_STRING "@PV_VERSION_STRING@"
+
+#endif
index 41f85897893069165afc325d5db4d65a414ab36e..661c84a6d23c0ea40d128a52fe8584608f624fd7 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -26,14 +26,17 @@ extern "C" {
 
 #include <QtGui/QApplication>
 #include <QDebug>
+
 #include "pv/mainwindow.h"
 
+#include "config.h"
+
 int main(int argc, char *argv[])
 {
        QApplication a(argc, argv);
 
        /* Set some application metadata. */
-       QApplication::setApplicationVersion(APP_VERSION);
+       QApplication::setApplicationVersion(PV_VERSION_STRING);
        QApplication::setApplicationName("PulseView");
        QApplication::setOrganizationDomain("http://www.sigrok.org");