Repository: opencv
Issue: Can not build on MacOS
Labels: bug,category: build/install,platform: ios/osx

### System Information

OpenCV Version: 4.10.0
Platform: MacOS 14
Compiler: Xcode 15.4
Python Version: 3.11

### Detailed description

When building OpenCV from source with the given setup the build will fail with the following error:
```
/Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/compiler/gislandmodel.hpp:166:24: error: field has incomplete type 'std::exception_ptr'
    std::exception_ptr eptr;
                       ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__exception/operations.h:36:33: note: forward declaration of 'std::exception_ptr'
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
                                ^
In file included from /Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/api/gbackend.cpp:14:
In file included from /Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/api/gbackend_priv.hpp:21:
In file included from /Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/compiler/gmodel.hpp:32:
/Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/compiler/gislandmodel.hpp:178:61: error: initialization of incomplete type 'const std::exception_ptr'
    virtual void post(GRunArgP&&, const std::exception_ptr& = {}) = 0; // Release the object back to the framework (mark available)
                                                            ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__exception/operations.h:36:33: note: forward declaration of 'std::exception_ptr'
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
                                ^
/Users/runner/work/Proxy-PDF-Maker/Proxy-PDF-Maker/.conan_home/p/b/opencc537d20d0094d/b/src/modules/gapi/src/compiler/gislandmodel.hpp:178:61: note: passing argument to parameter here
    virtual void post(GRunArgP&&, const std::exception_ptr& = {}) = 0; // Release the object back to the framework (mark available)
```

Highligh here is
```
error: field has incomplete type 'std::exception_ptr'
```
which appears due to a missing `#include <exception>`.

### Steps to reproduce

Run the following commands to build OpenCV:
```sh
cmake .. -G "Ninja" -DCMAKE_C_COMPILER=cc -DCMAKE_CXX_COMPILER=c++ -DCMAKE_BUILD_TYPE="Release"
cmake --build .
```

See also a build in Github Actions CI failing here: https://github.com/Malacath-92/Proxy-PDF-Maker/actions/runs/12786776491/job/35644533639
This build uses conan as a package manager, but it essentially executes the above commands during resolution of dependencies.

### 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)