1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #21114 from dwardor:patch-1

* Fix compile against lapack-3.10.0

Fix compilation against lapack >= 3.9.1 and 3.10.0 while not breaking older versions

OpenCVFindLAPACK.cmake & CMakeLists.txt: determine OPENCV_USE_LAPACK_PREFIX from LAPACK_VERSION

hal_internal.cpp : Only apply LAPACK_FUNC to functions whose number of inputs depends on LAPACK_FORTRAN_STR_LEN in lapack >= 3.9.1

lapack_check.cpp : remove LAPACK_FUNC which is not OK as function are not used with input parameters (so lapack.h preprocessing of "LAPACK_xxxx(...)" is not applicable with lapack >= 3.9.1
If not removed lapack_check fails so LAPACK is deactivated in build (not want we want)

use OCV_ prefix and don't use Global, instead generate OCV_LAPACK_FUNC depending on CMake Conditions

Remove CONFIG from find_package(LAPACK) and use LAPACK_GLOBAL and LAPACK_NAME to figure out if using netlib's reference LAPACK implementation and how to #define OCV_LAPACK_FUNC(f)

* Fix typos and grammar in comments
This commit is contained in:
dwardor
2021-12-22 13:00:00 +01:00
committed by GitHub
parent 6e733b65ae
commit 54c180092d
2 changed files with 35 additions and 18 deletions
+17
View File
@@ -51,6 +51,23 @@ macro(ocv_lapack_check)
if(NOT "${OPENCV_CBLAS_H_PATH_${_lapack_impl}}" STREQUAL "${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}")
list(APPEND _lapack_content "#include \"${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}\"")
endif()
list(APPEND _lapack_content "
#if defined(LAPACK_GLOBAL) || defined(LAPACK_NAME)
/*
* Using netlib's reference LAPACK implementation version >= 3.4.0 (first with C interface).
* Use LAPACK_xxxx to transparently (via predefined lapack macros) deal with pre and post 3.9.1 versions.
* LAPACK 3.9.1 introduces LAPACK_FORTRAN_STRLEN_END and modifies (through preprocessing) the declarations of the following functions used in opencv
* sposv_, dposv_, spotrf_, dpotrf_, sgesdd_, dgesdd_, sgels_, dgels_
* which end up with an extra parameter.
* So we also need to preprocess the function calls in opencv coding by prefixing them with LAPACK_.
* The good news is the preprocessing works fine whatever netlib's LAPACK version.
*/
#define OCV_LAPACK_FUNC(f) LAPACK_##f
#else
/* Using other LAPACK implementations so fall back to opencv's assumption until now */
#define OCV_LAPACK_FUNC(f) f##_
#endif
")
if(${_lapack_add_extern_c})
list(APPEND _lapack_content "}")
endif()