From 9bc7fd3ad241daf464fe065667ded711fdaee160 Mon Sep 17 00:00:00 2001
From: Alexandru Croitor <alexandru.croitor@qt.io>
Date: Mon, 16 Jul 2018 13:24:51 +0200
Subject: [PATCH] Fix Xcode version check to work with major versions >= 10
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We used lessThan for the Xcode version check, which started to fail
when comparing Xcode 10 with Xcode 7.3, because lessThan first tries
to convert the arguments to ints and if that fails, it does string
comparison instead.

Rewrite the code to be similar to the SDK checks.
We can't use the qmake versionAtLeast function because it was added
in Qt 5.10, and we still need to be able to build against Qt 5.9.

Task-number: QTBUG-69476
Change-Id: I831a683ee676838a4d531a4d6e715182e9e4193d
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
(cherry picked from commit 0fc07d2943753f444f3eeccd9fb1dfde0938cb70)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
---
 mkspecs/features/functions.prf | 22 +++++++++++++++++++++-
 src/3rdparty                   |  2 +-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf
index b78d2a11..ac0c9837 100644
--- tools/qmake/mkspecs/features/functions.prf
+++ tools/qmake/mkspecs/features/functions.prf
@@ -43,7 +43,7 @@ defineTest(isPlatformSupported) {
       return(false)
     }
   } else:osx {
-    lessThan(QMAKE_XCODE_VERSION, 5.1) {
+    !isMinXcodeVersion(5, 1) {
       skipBuild("Using XCode version $$QMAKE_XCODE_VERSION, but at least version 5.1 is required to build Qt WebEngine.")
       return(false)
     }
@@ -255,6 +255,26 @@ defineTest(isMinOSXSDKVersion) {
     return(false)
 }
 
+defineTest(isMinXcodeVersion) {
+    requested_major = $$1
+    requested_minor = $$2
+    requested_patch = $$3
+    isEmpty(requested_minor): requested_minor = 0
+    isEmpty(requested_patch): requested_patch = 0
+    target_var = QMAKE_XCODE_VERSION
+    major_version = $$section($$target_var, ., 0, 0)
+    minor_version = $$section($$target_var, ., 1, 1)
+    patch_version = $$section($$target_var, ., 2, 2)
+    isEmpty(minor_version): minor_version = 0
+    isEmpty(patch_version): patch_version = 0
+
+    greaterThan(major_version, $$requested_major):return(true)
+    equals(major_version, $$requested_major):greaterThan(minor_version, $$requested_minor):return(true)
+    equals(major_version, $$requested_major):equals(minor_version, $$requested_minor):!lessThan(patch_version, $$requested_patch):return(true)
+
+    return(false)
+}
+
 defineTest(isMinWinSDKVersion) {
     requested_major = $$1
     requested_minor = $$2
