Merge pull request #28203 from AdwaithBatchu:fix-macos-lapack-warnings

core: suppress LAPACK deprecation warnings on macOS #28203

### Description
On macOS (Apple Silicon) with newer Xcode/Clang, the CLAPACK interface is deprecated.
Compiling `hal_internal.cpp` triggers multiple warnings like:
`warning: 'sgesv_' is deprecated: first deprecated in macOS 13.3 - The CLAPACK interface is deprecated. [-Wdeprecated-declarations]`

Since migrating to the new Accelerate interface (Apple's recommended fix) requires significant changes to the HAL implementation and breaks the build if headers are mismatched, this PR takes the pragmatic approach. It suppresses the `-Wdeprecated-declarations` warning for this specific file using Clang pragmas to clean up the build output.

### Verification
- [x] Verified build is silent on macOS (M3).
- [x] Verified pragmas are correctly scoped within `HAVE_LAPACK` to prevent scope mismatch on non-LAPACK builds.

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
AdwaithBatchu
2025-12-18 16:23:56 +05:30
committed by GitHub
parent dc52acc7d1
commit 87f4a9782c
4 changed files with 34 additions and 1 deletions

View File

@@ -44,6 +44,10 @@
#elif defined(HAVE_LAPACK)
#include "opencv_lapack.h"
#endif
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace cv { namespace usac {
class DLSPnPImpl : public DLSPnP {
@@ -890,3 +894,7 @@ Ptr<DLSPnP> DLSPnP::create(const Mat &points_, const Mat &calib_norm_pts, const
return makePtr<DLSPnPImpl>(points_, calib_norm_pts, K);
}
}}
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -9,6 +9,10 @@
#elif defined(HAVE_LAPACK)
#include "opencv_lapack.h"
#endif
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace cv { namespace usac {
/*
@@ -354,3 +358,7 @@ Ptr<EssentialMinimalSolver5pts> EssentialMinimalSolver5pts::create
return makePtr<EssentialMinimalSolver5ptsImpl>(points_, use_svd, is_nister);
}
}}
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -11,6 +11,10 @@
#elif defined(HAVE_LAPACK)
#include "opencv_lapack.h"
#endif
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace cv { namespace usac {
class PnPMinimalSolver6PtsImpl : public PnPMinimalSolver6Pts {
@@ -412,3 +416,7 @@ Ptr<P3PSolver> P3PSolver::create(const Mat &points_, const Mat &calib_norm_pts,
return makePtr<P3PSolverImpl>(points_, calib_norm_pts, K);
}
}}
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

@@ -77,6 +77,11 @@ __msan_unpoison(address, size)
#define CV_ANNOTATE_NO_SANITIZE_MEMORY
#endif
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
//lapack stores matrices in column-major order so transposing is needed everywhere
template <typename fptype> static inline void
transpose_square_inplace(fptype *src, size_t src_ld, size_t m)
@@ -701,4 +706,8 @@ int lapack_gemm64fc(const double *src1, size_t src1_step, const double *src2, si
return lapack_gemm_c(src1, src1_step, src2, src2_step, alpha, src3, src3_step, beta, dst, dst_step, m, n, k, flags);
}
#endif //HAVE_LAPACK
#if defined(__APPLE__) && defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif //HAVE_LAPACK