From: Alexandru Gagniuc Date: Fri, 12 Oct 2012 20:38:06 +0000 (-0500) Subject: Generate a config.h file for versioning X-Git-Tag: pulseview-0.1.0~265 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=075fb4995aaaf521502571d26da62a6923555eff Generate a config.h file for versioning 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 60d7bfac..2448a32f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 00000000..ea9b0d4a --- /dev/null +++ b/config.h.in @@ -0,0 +1,29 @@ +/* + * This file is part of pulseview. + * + * Copyright (C) 2012 Alexandru Gagniuc + * + * 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 . + */ + +#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 diff --git a/main.cpp b/main.cpp index 41f85897..661c84a6 100644 --- a/main.cpp +++ b/main.cpp @@ -26,14 +26,17 @@ extern "C" { #include #include + #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");