From eff3b42cb08062a6154d26f3fc352dd891e5c2ed Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Wed, 30 Jan 2019 21:23:26 +0100 Subject: [PATCH] Added version number and optional build number to build system --- CMakeLists.txt | 3 ++- source/CMakeLists.txt | 20 +++++++++++++++++++- source/ESGRAF48.cpp | 9 ++++++--- source/version.h.in | 4 ++++ 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 source/version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a8da5b..a731ba0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(cmake/conan.cmake) conan_cmake_run(CONANFILE conanfile.txt BASIC_SETUP - BUILD missing) + BUILD missing +) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 0a0f40f..75f11e5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -1,6 +1,24 @@ cmake_minimum_required(VERSION 3.6) -project(ESGRAF48 LANGUAGES CXX) +set(BUILD_VERSION_MAJOR_MINOR 0.1) + +if ($ENV{BUILD_NUMBER}) + set(BUILD_VERSION_PATCH $ENV{BUILD_NUMBER}) +else() + set(BUILD_VERSION_PATCH 0) +endif() + +project(ESGRAF48 + VERSION ${BUILD_VERSION_MAJOR_MINOR}.${BUILD_VERSION_PATCH} + DESCRIPTION "ESGRAF 4-8" + LANGUAGES CXX +) + +configure_file( + version.h.in + version.h +) + find_package(Qt5Widgets REQUIRED) find_package(Qt5PrintSupport REQUIRED) diff --git a/source/ESGRAF48.cpp b/source/ESGRAF48.cpp index 40b8801..9e39190 100644 --- a/source/ESGRAF48.cpp +++ b/source/ESGRAF48.cpp @@ -1,15 +1,18 @@ #include "mainwindow.h" + +#include "version.h" + #include #include int main(int argc, char **argv) { QApplication app(argc, argv); - QCoreApplication::setApplicationName("ESGRAF 4-8"); - QCoreApplication::setApplicationVersion("0.1"); + QCoreApplication::setApplicationName(ESGRAF48_DESCRIPTION); + QCoreApplication::setApplicationVersion(ESGRAF48_VERSION); QCommandLineParser cmdParser; - cmdParser.setApplicationDescription("ESGRAF 4-8"); + cmdParser.setApplicationDescription(ESGRAF48_DESCRIPTION); cmdParser.addHelpOption(); cmdParser.addVersionOption(); cmdParser.addPositionalArgument("filename", "file to open"); diff --git a/source/version.h.in b/source/version.h.in new file mode 100644 index 0000000..dedd89c --- /dev/null +++ b/source/version.h.in @@ -0,0 +1,4 @@ +#pragma once + +#define ESGRAF48_VERSION "@PROJECT_VERSION@" +#define ESGRAF48_DESCRIPTION "@PROJECT_DESCRIPTION@"