From 4a3ee6a74a1416451cfc94be9be788b39e2f97ec Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 5 Jan 2017 10:57:00 +0000 Subject: [PATCH] Relax base-package and SimGear version checks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As discussed on the devel list, only require the major+minor versions of FG+SG+data to match by default. If we encounter a situation on a release branch where stronger checks are needed, it’s easy to restore. --- CMakeLists.txt | 13 +++++++++++-- src/Main/options.cxx | 13 +++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be2584b4e..ae717fabd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,8 +314,17 @@ endif (ENABLE_QT) find_package(PLIB REQUIRED puaux pu js fnt) -# FlightGear and SimGear versions need to match -find_package(SimGear ${FLIGHTGEAR_VERSION} CONFIG REQUIRED) +# FlightGear and SimGear versions need to match major + minor +# split version string into components, note CMAKE_MATCH_0 is the entire regexp match +string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSION_REGEX ${FLIGHTGEAR_VERSION} ) +set(FG_VERSION_MAJOR ${CMAKE_MATCH_1}) +set(FG_VERSION_MINOR ${CMAKE_MATCH_2}) +set(FG_VERSION_PATCH ${CMAKE_MATCH_3}) + +set(MIN_SIMGEAR_VERSION "${FG_VERSION_MAJOR}.${FG_VERSION_MINOR}.0") +message(STATUS "Min Simgear version is ${MIN_SIMGEAR_VERSION}") + +find_package(SimGear ${MIN_SIMGEAR_VERSION} CONFIG REQUIRED) ############################################################################## diff --git a/src/Main/options.cxx b/src/Main/options.cxx index ad12ba0ec..96a6fb538 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2711,15 +2711,18 @@ void Options::setupRoot(int argc, char **argv) } globals->set_fg_root(root); - static char required_version[] = FLIGHTGEAR_VERSION; string base_version = fgBasePackageVersion(root); + #if defined(HAVE_QT) + // only compare major and minor version, not the patch level. + const int versionComp = simgear::strutils::compare_versions(FLIGHTGEAR_VERSION, base_version, 2); + // note we never end up here if restoring a user selected root via // the Qt GUI, since that code pre-validates the path. But if we're using // a command-line, env-var or default root this check can fail and // we still want to use the GUI in that case - if (base_version != required_version) { + if (versionComp != 0) { flightgear::initApp(argc, argv); SetupRootDialog::runDialog(usingDefaultRoot); } @@ -2733,12 +2736,14 @@ void Options::setupRoot(int argc, char **argv) exit(-1); } - if (base_version != required_version) { + // only compare major and minor version, not the patch level. + const int versionComp = simgear::strutils::compare_versions(FLIGHTGEAR_VERSION, base_version, 2); + if (versionComp != 0) { flightgear::fatalMessageBox("Base package version mismatch", "Version check failed: please check your installation.", "Found data files for version '" + base_version + "' at '" + globals->get_fg_root().str() + "', version '" - + required_version + "' is required."); + + std::string(FLIGHTGEAR_VERSION) + "' is required."); exit(-1); }