From 19bef4fce8cf490be89c40057ab498fe30d0394f Mon Sep 17 00:00:00 2001 From: pvdk Date: Thu, 23 Jan 2014 13:18:05 +0100 Subject: [PATCH] Distinguish between release and development builds --- CMakeLists.txt | 23 ++++++++++++----------- apps/launcher/maindialog.cpp | 12 +++++++++--- components/version/version.hpp.cmake | 3 ++- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bd2cdddc..01ac9b23f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,23 +20,24 @@ include(OpenMWMacros) include(GetGitRevisionDescription) -get_git_tag_revision(taghash --tags --max-count=1) -get_git_head_revision(refspec commithash) -git_describe(version --tags ${taghash}) +get_git_tag_revision(TAGHASH --tags --max-count=1) +get_git_head_revision(REFSPEC COMMITHASH) +git_describe(VERSION --tags ${TAGHASH}) -string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" match "${version}") -if (match) - string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${version}") - string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${version}") - string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${version}") +string(REGEX MATCH "^openmw-[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" MATCH "${VERSION}") +if (MATCH) + string(REGEX REPLACE "^openmw-([0-9]+)\\..*" "\\1" OPENMW_VERSION_MAJOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_MINOR "${VERSION}") + string(REGEX REPLACE "^openmw-[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" OPENMW_VERSION_RELEASE "${VERSION}") set(OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") - set(OPENMW_VERSION_COMMIT "${commithash}") + set(OPENMW_VERSION_COMMITHASH "${COMMITHASH}") + set(OPENMW_VERSION_TAGHASH "${TAGHASH}") message(STATUS "Configuring OpenMW ${OPENMW_VERSION}...") -else (match) +else (MATCH) message(FATAL_ERROR "Failed to get valid version information from Git") -endif (match) +endif (MATCH) # doxygen main page diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 42d3d1754..67665adf0 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -73,13 +73,19 @@ Launcher::MainDialog::MainDialog(QWidget *parent) setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); // Add version information to bottom of the window - QString revision(OPENMW_VERSION_COMMIT); - revision = revision.left(10); + QString revision(OPENMW_VERSION_COMMITHASH); + QString tag(OPENMW_VERSION_TAGHASH); + if (revision == tag) { + versionLabel->setText(tr("OpenMW %0 release").arg(OPENMW_VERSION)); + } else { + versionLabel->setText(tr("OpenMW unstable, revision %0").arg(revision.left(10))); + } + + // Add the compile date and time QDate date(QDate::fromString(__DATE__, QLatin1String("MMM dd yyyy"))); QTime time(QTime::fromString(__TIME__, QLatin1String("hh:m:ss"))); - versionLabel->setText(tr("OpenMW %0 revision %1").arg(OPENMW_VERSION, revision)); versionLabel->setToolTip(tr("Compiled on %0 %1").arg(date.toString(Qt::SystemLocaleShortDate), time.toString(Qt::SystemLocaleShortDate))); diff --git a/components/version/version.hpp.cmake b/components/version/version.hpp.cmake index 4adb0d8c2..4cdfa32f0 100644 --- a/components/version/version.hpp.cmake +++ b/components/version/version.hpp.cmake @@ -6,7 +6,8 @@ #define OPENMW_VERSION_RELEASE @OPENMW_VERSION_RELEASE@ #define OPENMW_VERSION "@OPENMW_VERSION@" -#define OPENMW_VERSION_COMMIT "@OPENMW_VERSION_COMMIT@" +#define OPENMW_VERSION_COMMITHASH "@OPENMW_VERSION_COMMITHASH@" +#define OPENMW_VERSION_TAGHASH "@OPENMW_VERSION_TAGHASH@" #endif // VERSION_HPP