From 1bef8b81f441e9a8f860fc965e5e937b68054954 Mon Sep 17 00:00:00 2001 From: Samaresh Kumar Singh Date: Tue, 7 Apr 2026 21:24:04 -0500 Subject: [PATCH] cmake: find and link libcblas separately for LAPACK/Generic On systems like OpenBSD, CBLAS functions are provided by a standalone libcblas that is not returned by find_package(LAPACK). This caused link failures when building libopencv_core because cblas_sgemm and friends from hal_internal.cpp could not be resolved. Fixes #28768 --- cmake/OpenCVFindLAPACK.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVFindLAPACK.cmake b/cmake/OpenCVFindLAPACK.cmake index 3b1c435bdf..61a149c234 100644 --- a/cmake/OpenCVFindLAPACK.cmake +++ b/cmake/OpenCVFindLAPACK.cmake @@ -230,11 +230,18 @@ if(WITH_LAPACK) find_path(CBLAS_INCLUDE_DIR "cblas.h") endif() if(CBLAS_INCLUDE_DIR AND LAPACKE_INCLUDE_DIR) + if(NOT DEFINED CBLAS_LIBRARY) + find_library(CBLAS_LIBRARY cblas) + endif() + set(_lapack_generic_libs "${LAPACK_LIBRARIES}") + if(CBLAS_LIBRARY) + list(APPEND _lapack_generic_libs "${CBLAS_LIBRARY}") + endif() ocv_lapack_check(IMPL "LAPACK/Generic" CBLAS_H "cblas.h" LAPACKE_H "lapacke.h" INCLUDE_DIR "${CBLAS_INCLUDE_DIR}" "${LAPACKE_INCLUDE_DIR}" - LIBRARIES "${LAPACK_LIBRARIES}") + LIBRARIES "${_lapack_generic_libs}") elseif(APPLE) ocv_lapack_check(IMPL "LAPACK/Apple" CBLAS_H "Accelerate/Accelerate.h"