diff --git a/CMakeLists.txt b/CMakeLists.txt index 90b4a2669b..ed996d17d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,7 @@ endif() include(cmake/OpenCVMinDepVersions.cmake) -if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3) - cmake_minimum_required(VERSION 3.0 FATAL_ERROR) -elseif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) +if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) cmake_minimum_required(VERSION 3.1 FATAL_ERROR) #Required to resolve linker error issues due to incompatibility with CMake v3.0+ policies. #CMake fails to find _fseeko() which leads to subsequent linker error. diff --git a/platforms/ios/build_framework.py b/platforms/ios/build_framework.py index 7b05a019d3..bd27dcf731 100755 --- a/platforms/ios/build_framework.py +++ b/platforms/ios/build_framework.py @@ -37,7 +37,7 @@ from subprocess import check_call, check_output, CalledProcessError from distutils.dir_util import copy_tree sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple')) -from cv_build_utils import execute, print_error, get_xcode_major, get_xcode_setting +from cv_build_utils import execute, print_error, get_xcode_major, get_xcode_setting, get_xcode_version, get_cmake_version IPHONEOS_DEPLOYMENT_TARGET='9.0' # default, can be changed via command line options or environment variable @@ -64,6 +64,12 @@ class Builder: self.run_tests = run_tests self.build_docs = build_docs + def checkCMakeVersion(self): + if get_xcode_version() >= (12, 2): + assert get_cmake_version() >= (3, 19), "CMake 3.19 or later is required when building with Xcode 12.2 or greater. Current version is {}".format(get_cmake_version()) + else: + assert get_cmake_version() >= (3, 17), "CMake 3.17 or later is required. Current version is {}".format(get_cmake_version()) + def getBuildDir(self, parent, target): res = os.path.join(parent, 'build-%s-%s' % (target[0].lower(), target[1].lower())) @@ -73,6 +79,7 @@ class Builder: return os.path.abspath(res) def _build(self, outdir): + self.checkCMakeVersion() outdir = os.path.abspath(outdir) if not os.path.isdir(outdir): os.makedirs(outdir) diff --git a/platforms/osx/build_framework.py b/platforms/osx/build_framework.py index 95c8268454..32cd00aed7 100755 --- a/platforms/osx/build_framework.py +++ b/platforms/osx/build_framework.py @@ -10,12 +10,15 @@ import os, os.path, sys, argparse, traceback, multiprocessing sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios')) from build_framework import Builder sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../apple')) -from cv_build_utils import print_error +from cv_build_utils import print_error, get_cmake_version MACOSX_DEPLOYMENT_TARGET='10.12' # default, can be changed via command line options or environment variable class OSXBuilder(Builder): + def checkCMakeVersion(self): + assert get_cmake_version() >= (3, 17), "CMake 3.17 or later is required. Current version is {}".format(get_cmake_version()) + def getObjcTarget(self, target): # Obj-C generation target if target == "Catalyst":