Repository: opencv
Issue: Unable to compile opencv iOS in MacBook M2 Ventura 13.4
Labels: bug,category: build/install,platform: ios/osx,needs investigation

### System Information

_Python version_: 3.9.12
_Computer_: MacBook Pro Max M2
_OS_: MacOS Ventura 13.4
_XCode Version_: 14.3 (14E222b)
_OpenCV version_: 4.7.0

```
g++ --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: arm64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
```

### Detailed description

```
% python ../opencv/platforms/ios/build_framework.py ios
```
Produces this output:
```
Using IPHONEOS_DEPLOYMENT_TARGET=9.0
Using iPhoneOS ARCHS=['armv7', 'armv7s', 'arm64']
Using iPhoneSimulator ARCHS=['i386', 'x86_64']

=================================
CMake
=================================

Executing: ['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DFRAMEWORK_NAME=opencv2', '-DIOS_ARCH=armv7', '-DCMAKE_TOOLCHAIN_FILE=/GitHub/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', '/GitHub/opencv', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode'] in /GitHub/opencv/ios/build/build-armv7-iphoneos
Executing: cmake -GXcode -DAPPLE_FRAMEWORK=ON -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DOPENCV_INCLUDE_INSTALL_PATH=include -DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty -DFRAMEWORK_NAME=opencv2 -DIOS_ARCH=armv7 -DCMAKE_TOOLCHAIN_FILE=/GitHub/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake -DCPU_BASELINE=DETECT /GitHub/opencv -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode
-- Setting up iPhoneOS toolchain for IOS_ARCH='armv7'
-- iPhoneOS toolchain loaded
-- Setting up iPhoneOS toolchain for IOS_ARCH='armv7'
-- iPhoneOS toolchain loaded
-- The CXX compiler identification is AppleClang 14.0.3.14030022
-- The C compiler identification is AppleClang 14.0.3.14030022
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Detected processor: armv7
-- Looking for ccache - not found
-- Performing Test HAVE_CXX_FSIGNED_CHAR
-- Performing Test HAVE_CXX_FSIGNED_CHAR - Failed
-- Performing Test HAVE_C_FSIGNED_CHAR
-- Performing Test HAVE_C_FSIGNED_CHAR - Failed
-- Performing Test HAVE_CXX_W
-- Performing Test HAVE_CXX_W - Failed
-- Performing Test HAVE_C_W
-- Performing Test HAVE_C_W - Failed
-- Performing Test HAVE_CXX_WALL
-- Performing Test HAVE_CXX_WALL - Failed
-- Performing Test HAVE_C_WALL
-- Performing Test HAVE_C_WALL - Failed
-- Performing Test HAVE_CXX_WRETURN_TYPE
-- Performing Test HAVE_CXX_WRETURN_TYPE - Failed
-- Performing Test HAVE_C_WRETURN_TYPE
-- Performing Test HAVE_C_WRETURN_TYPE - Failed
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WADDRESS
-- Performing Test HAVE_CXX_WADDRESS - Failed
-- Performing Test HAVE_C_WADDRESS
-- Performing Test HAVE_C_WADDRESS - Failed
-- Performing Test HAVE_CXX_WSEQUENCE_POINT
-- Performing Test HAVE_CXX_WSEQUENCE_POINT - Failed
-- Performing Test HAVE_C_WSEQUENCE_POINT
-- Performing Test HAVE_C_WSEQUENCE_POINT - Failed
-- Performing Test HAVE_CXX_WFORMAT
-- Performing Test HAVE_CXX_WFORMAT - Failed
-- Performing Test HAVE_C_WFORMAT
-- Performing Test HAVE_C_WFORMAT - Failed
-- Performing Test HAVE_CXX_WFORMAT_SECURITY
-- Performing Test HAVE_CXX_WFORMAT_SECURITY - Failed
-- Performing Test HAVE_C_WFORMAT_SECURITY
-- Performing Test HAVE_C_WFORMAT_SECURITY - Failed
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS
-- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Failed
-- Performing Test HAVE_C_WMISSING_DECLARATIONS
-- Performing Test HAVE_C_WMISSING_DECLARATIONS - Failed
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES
-- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_C_WMISSING_PROTOTYPES
-- Performing Test HAVE_C_WMISSING_PROTOTYPES - Failed
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES
-- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES
-- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Failed
-- Performing Test HAVE_CXX_WUNDEF
-- Performing Test HAVE_CXX_WUNDEF - Failed
-- Performing Test HAVE_C_WUNDEF
-- Performing Test HAVE_C_WUNDEF - Failed
-- Performing Test HAVE_CXX_WINIT_SELF
-- Performing Test HAVE_CXX_WINIT_SELF - Failed
-- Performing Test HAVE_C_WINIT_SELF
-- Performing Test HAVE_C_WINIT_SELF - Failed
-- Performing Test HAVE_CXX_WPOINTER_ARITH
-- Performing Test HAVE_CXX_WPOINTER_ARITH - Failed
-- Performing Test HAVE_C_WPOINTER_ARITH
-- Performing Test HAVE_C_WPOINTER_ARITH - Failed
-- Performing Test HAVE_CXX_WSHADOW
-- Performing Test HAVE_CXX_WSHADOW - Failed
-- Performing Test HAVE_C_WSHADOW
-- Performing Test HAVE_C_WSHADOW - Failed
-- Performing Test HAVE_CXX_WSIGN_PROMO
-- Performing Test HAVE_CXX_WSIGN_PROMO - Failed
-- Performing Test HAVE_C_WSIGN_PROMO
-- Performing Test HAVE_C_WSIGN_PROMO - Failed
-- Performing Test HAVE_CXX_WUNINITIALIZED
-- Performing Test HAVE_CXX_WUNINITIALIZED - Failed
-- Performing Test HAVE_C_WUNINITIALIZED
-- Performing Test HAVE_C_WUNINITIALIZED - Failed
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR
-- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Performing Test HAVE_CXX_WNO_COMMENT
-- Performing Test HAVE_CXX_WNO_COMMENT - Failed
-- Performing Test HAVE_C_WNO_COMMENT
-- Performing Test HAVE_C_WNO_COMMENT - Failed
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Failed
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION
-- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Failed
-- Performing Test HAVE_CXX_QUNUSED_ARGUMENTS
-- Performing Test HAVE_CXX_QUNUSED_ARGUMENTS - Failed
-- Performing Test HAVE_C_QUNUSED_ARGUMENTS
-- Performing Test HAVE_C_QUNUSED_ARGUMENTS - Failed
-- Performing Test HAVE_CXX_WNO_SEMICOLON_BEFORE_METHOD_BODY
-- Performing Test HAVE_CXX_WNO_SEMICOLON_BEFORE_METHOD_BODY - Failed
-- Performing Test HAVE_C_WNO_SEMICOLON_BEFORE_METHOD_BODY
-- Performing Test HAVE_C_WNO_SEMICOLON_BEFORE_METHOD_BODY - Failed
-- Performing Test HAVE_CXX_MFPU_VFPV3
-- Performing Test HAVE_CXX_MFPU_VFPV3 - Failed
-- VFPV3 is not supported by C++ compiler
-- Performing Test HAVE_CPU_NEON_SUPPORT (check file: cmake/checks/cpu_neon.cpp)
-- Performing Test HAVE_CPU_NEON_SUPPORT - Failed
-- Performing Test HAVE_CXX_MFPU_NEON (check file: cmake/checks/cpu_neon.cpp)
-- Performing Test HAVE_CXX_MFPU_NEON - Failed
-- NEON is not supported by C++ compiler
-- Performing Test HAVE_CPU_FP16_SUPPORT (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CPU_FP16_SUPPORT - Failed
-- Performing Test HAVE_CXX_MFPU_NEON_FP16_MFP16_FORMAT_IEEE (check file: cmake/checks/cpu_fp16.cpp)
-- Performing Test HAVE_CXX_MFPU_NEON_FP16_MFP16_FORMAT_IEEE - Failed
-- FP16 is not supported by C++ compiler
-- Performing Test HAVE_CPU_BASELINE_FLAGS
-- Performing Test HAVE_CPU_BASELINE_FLAGS - Failed

CMake Error at cmake/OpenCVCompilerOptimizations.cmake:611 (message):
  Compiler doesn't support baseline optimization flags:
Call Stack (most recent call first):
  cmake/OpenCVCompilerOptions.cmake:327 (ocv_compiler_optimization_options)
  CMakeLists.txt:650 (include)

-- Configuring incomplete, errors occurred!
============================================================
ERROR: Command '['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DFRAMEWORK_NAME=opencv2', '-DIOS_ARCH=armv7', '-DCMAKE_TOOLCHAIN_FILE=/GitHub/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', 'GitHub/opencv', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode']' returned non-zero exit status 1.
============================================================
Traceback (most recent call last):
  File "/GitHub/opencv/../opencv/platforms/ios/build_framework.py", line 181, in build
    self._build(outdir)
  File "/GitHub/opencv/../opencv/platforms/ios/build_framework.py", line 139, in _build
    self.buildOne(target[0], target[1], main_build_dir, cmake_flags)
  File "/GitHub/opencv/../opencv/platforms/ios/build_framework.py", line 306, in buildOne
    execute(cmakecmd, cwd = builddir)
  File "/GitHub/opencv/platforms/apple/cv_build_utils.py", line 13, in execute
    retcode = check_call(cmd, cwd = cwd)
  File "/Users/<user>/opt/anaconda3/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-GXcode', '-DAPPLE_FRAMEWORK=ON', '-DCMAKE_INSTALL_PREFIX=install', '-DCMAKE_BUILD_TYPE=Release', '-DOPENCV_INCLUDE_INSTALL_PATH=include', '-DOPENCV_3P_LIB_INSTALL_PATH=lib/3rdparty', '-DFRAMEWORK_NAME=opencv2', '-DIOS_ARCH=armv7', '-DCMAKE_TOOLCHAIN_FILE=/GitHub/opencv/platforms/ios/cmake/Toolchains/Toolchain-iPhoneOS_Xcode.cmake', '-DCPU_BASELINE=DETECT', '/GitHub/opencv', '-DCMAKE_C_FLAGS=-fembed-bitcode', '-DCMAKE_CXX_FLAGS=-fembed-bitcode']' returned non-zero exit status 1.
```



### Steps to reproduce

```
% python ../opencv/platforms/ios/build_framework.py ios
```

### Issue submission checklist

- [X] I report the issue, it's not a question
- [X] I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- [ ] I updated to the latest OpenCV version and the issue is still there
- [ ] There is reproducer code and related data files (videos, images, onnx, etc)