Repository: opencv
Issue: Unable to build macOS Catalyst version of OpenCV framework (osx/build_frameworks.py)
Labels: bug,duplicate,category: build/install,platform: ios/osx

### System Information

OpenCV version: 4.7.0 (but I also tried 4.6.0)
Operating system: macOS 13.3.1 / Apple M2 Pro chip
Cmake version: 3.26 (but tried also other versions)



### Detailed description

I am building XCFramework from openCV sources. When I try to build for simulator, device or macOS archs, everything works. However, when I want to include Mac Catalyst arc, the build fails.

I tried different openCV versions (4.6.0, 4.5.0) and CMake versions (3.26, 3.25, 3.24).

What I realised, that the problem is not in build_xcframework.py, but in build_xframework.py in in platforms/osx directory. So that can be isolated to this script.


### Steps to reproduce

run build_framework from platforms/osx
```bash
python build_framework.py --catalyst_archs arm64 --framework_name opencv2 out --build_only_specified_archs
```

I got error:

```
CMake Error at CMakeLists.txt:160 (message):
  CMake fails to determine the bitness of the target platform.

    Please check your CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.
```

The complete log from build script:

```
Using MacOS ARCHS=None
Using Catalyst ARCHS=['arm64']

=================================
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', '/Users/sarsonj/work/git/opencv-4.7.0', '-DCMAKE_C_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include', '-DCMAKE_CXX_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include', '-DCMAKE_EXE_LINKER_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include', '-DSWIFT_DISABLED=1', '-DIOS=1', '-DMAC_CATALYST=1', '-DWITH_OPENCL=OFF', '-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk', '-DCMAKE_CXX_COMPILER_WORKS=TRUE', '-DCMAKE_C_COMPILER_WORKS=TRUE'] in /Users/sarsonj/work/git/opencv-4.7.0/platforms/osx/out/build/build-arm64-catalyst
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 /Users/sarsonj/work/git/opencv-4.7.0 -DCMAKE_C_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include -DCMAKE_CXX_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include -DCMAKE_EXE_LINKER_FLAGS=-target arm64-apple-ios13.0-macabi -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/System/Library/Frameworks -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/iOSSupport/usr/include -DSWIFT_DISABLED=1 -DIOS=1 -DMAC_CATALYST=1 -DWITH_OPENCL=OFF -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -DCMAKE_CXX_COMPILER_WORKS=TRUE -DCMAKE_C_COMPILER_WORKS=TRUE
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- The C compiler identification is AppleClang 14.0.0.14000029
-- 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
-- ocv_init_download: OpenCV source tree is not fetched as git repository. 3rdparty resources will be downloaded from github.com by default.
CMake Error at CMakeLists.txt:160 (message):
  CMake fails to determine the bitness of the target platform.

    Please check your CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.
```



### 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
- [X] I updated to the latest OpenCV version and the issue is still there
- [X] There is reproducer code and related data files (videos, images, onnx, etc)