diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a746764f7..cc45f6f394 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,7 +227,7 @@ OCV_OPTION(WITH_VA "Include VA support" OFF OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) ) OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) ) -OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID) ) +OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID AND NOT IOS) ) # OpenCV build components # =================================================== @@ -556,6 +556,7 @@ include(cmake/OpenCVFindLibsGrfmt.cmake) include(cmake/OpenCVFindLibsGUI.cmake) include(cmake/OpenCVFindLibsVideo.cmake) include(cmake/OpenCVFindLibsPerf.cmake) +include(cmake/OpenCVFindLAPACK.cmake) # ---------------------------------------------------------------------------- # Detect other 3rd-party libraries/tools @@ -1222,7 +1223,7 @@ status(" Use Intel VA-API/OpenCL:" HAVE_VA_INTEL THEN "YES (MSDK: ${VA endif(DEFINED WITH_VA_INTEL) if(DEFINED WITH_LAPACK) -status(" Use Lapack:" HAVE_LAPACK THEN "YES" ELSE NO) +status(" Use Lapack:" HAVE_LAPACK THEN "YES (${LAPACK_LIBRARIES})" ELSE NO) endif(DEFINED WITH_LAPACK) status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO) diff --git a/cmake/OpenCVFindAtlas.cmake b/cmake/OpenCVFindAtlas.cmake new file mode 100644 index 0000000000..4fc7317749 --- /dev/null +++ b/cmake/OpenCVFindAtlas.cmake @@ -0,0 +1,97 @@ +#COPYRIGHT +# +#All contributions by the University of California: +#Copyright (c) 2014, 2015, The Regents of the University of California (Regents) +#All rights reserved. +# +#All other contributions: +#Copyright (c) 2014, 2015, the respective contributors +#All rights reserved. +# +#Caffe uses a shared copyright model: each contributor holds copyright over +#their contributions to Caffe. The project versioning records all such +#contribution and copyright details. If a contributor wants to further mark +#their specific copyright on a particular contribution, they should indicate +#their copyright solely in the commit message of the change when it is +#committed. +# +#LICENSE +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +#1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +#2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#CONTRIBUTION AGREEMENT +# +#By contributing to the BVLC/caffe repository through pull-request, comment, +#or otherwise, the contributor releases their content to the +#license and copyright terms herein. + + +# Find the Atlas (and Lapack) libraries +# +# The following variables are optionally searched for defaults +# Atlas_ROOT_DIR: Base directory where all Atlas components are found +# +# The following are set after configuration is done: +# Atlas_FOUND +# Atlas_INCLUDE_DIRS +# Atlas_LIBRARIES +# Atlas_LIBRARYRARY_DIRS + +set(Atlas_INCLUDE_SEARCH_PATHS + /usr/include/atlas + /usr/include/atlas-base + $ENV{Atlas_ROOT_DIR} + $ENV{Atlas_ROOT_DIR}/include +) + +set(Atlas_LIB_SEARCH_PATHS + /usr/lib/atlas + /usr/lib/atlas-base + $ENV{Atlas_ROOT_DIR} + $ENV{Atlas_ROOT_DIR}/lib +) + +find_path(Atlas_CBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS}) +find_path(Atlas_CLAPACK_INCLUDE_DIR NAMES lapacke.h PATHS ${Atlas_INCLUDE_SEARCH_PATHS}) + +find_library(Atlas_CBLAS_LIBRARY NAMES ptcblas_r ptcblas cblas_r cblas PATHS ${Atlas_LIB_SEARCH_PATHS}) +find_library(Atlas_BLAS_LIBRARY NAMES atlas_r atlas PATHS ${Atlas_LIB_SEARCH_PATHS}) +find_library(Atlas_LAPACK_LIBRARY NAMES lapack alapack_r alapack lapack_atlas PATHS ${Atlas_LIB_SEARCH_PATHS}) + +set(LOOKED_FOR + Atlas_CBLAS_INCLUDE_DIR + Atlas_CLAPACK_INCLUDE_DIR + + Atlas_CBLAS_LIBRARY + Atlas_BLAS_LIBRARY + Atlas_LAPACK_LIBRARY +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Atlas DEFAULT_MSG ${LOOKED_FOR}) + +if(ATLAS_FOUND) + set(Atlas_INCLUDE_DIR ${Atlas_CBLAS_INCLUDE_DIR} ${Atlas_CLAPACK_INCLUDE_DIR}) + set(Atlas_LIBRARIES ${Atlas_LAPACK_LIBRARY} ${Atlas_CBLAS_LIBRARY} ${Atlas_BLAS_LIBRARY}) + mark_as_advanced(${LOOKED_FOR}) + + message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})") +endif(ATLAS_FOUND) \ No newline at end of file diff --git a/cmake/OpenCVFindLAPACK.cmake b/cmake/OpenCVFindLAPACK.cmake new file mode 100644 index 0000000000..8e6e82ff3b --- /dev/null +++ b/cmake/OpenCVFindLAPACK.cmake @@ -0,0 +1,78 @@ +macro(_find_file_in_dirs VAR NAME DIRS) + find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH) + set(${VAR} ${${VAR}}/${NAME}) + unset(${VAR} CACHE) +endmacro() + +if(WITH_LAPACK) + ocv_update(LAPACK_IMPL "Unknown") + if(NOT LAPACK_LIBRARIES) + include(cmake/OpenCVFindMKL.cmake) + if(HAVE_MKL) + set(LAPACK_INCLUDE_DIR ${MKL_INCLUDE_DIRS}) + set(LAPACK_LIBRARIES ${MKL_LIBRARIES} ) + set(LAPACK_CBLAS_H "mkl_cblas.h" ) + set(LAPACK_LAPACKE_H "mkl_lapacke.h" ) + set(LAPACK_IMPL "MKL") + endif() + endif() + #if(NOT LAPACK_LIBRARIES) + # include(cmake/OpenCVFindOpenBLAS.cmake) + # if(OpenBLAS_FOUND) + # set(LAPACK_INCLUDE_DIR ${OpenBLAS_INCLUDE_DIR} ) + # set(LAPACK_LIBRARIES ${OpenBLAS_LIB} ) + # set(LAPACK_CBLAS_H "cblas.h" ) + # set(LAPACK_LAPACKE_H "lapacke.h" ) + # set(LAPACK_IMPL "OpenBLAS") + # endif() + #endif() + if(NOT LAPACK_LIBRARIES AND UNIX) + include(cmake/OpenCVFindAtlas.cmake) + if(ATLAS_FOUND) + set(LAPACK_INCLUDE_DIR ${Atlas_INCLUDE_DIR}) + set(LAPACK_LIBRARIES ${Atlas_LIBRARIES} ) + set(LAPACK_CBLAS_H "cblas.h" ) + set(LAPACK_LAPACKE_H "lapacke.h" ) + set(LAPACK_IMPL "Atlas") + endif() + endif() + + if(NOT LAPACK_LIBRARIES AND APPLE) + set(LAPACK_INCLUDE_DIR "Accelerate") + set(LAPACK_LIBRARIES "-framework Accelerate") + set(LAPACK_CBLAS_H "cblas.h" ) + set(LAPACK_LAPACKE_H "lapacke.h" ) + set(LAPACK_IMPL "Apple") + endif() + + set(LAPACK_INCLUDE_DIR ${LAPACK_INCLUDE_DIR} CACHE PATH "Path to BLAS include dir" FORCE) + set(LAPACK_CBLAS_H ${LAPACK_CBLAS_H} CACHE STRING "Alternative name of cblas.h" FORCE) + set(LAPACK_LAPACKE_H ${LAPACK_LAPACKE_H} CACHE STRING "Alternative name of lapacke.h" FORCE) + set(LAPACK_LIBRARIES ${LAPACK_LIBRARIES} CACHE STRING "Names of BLAS & LAPACK binaries (.so, .dll, .a, .lib)" FORCE) + set(LAPACK_IMPL ${LAPACK_IMPL} CACHE STRING "Lapack implementation id" FORCE) + + if(LAPACK_LIBRARIES) #adding proxy cblas.h header + message(STATUS "LAPACK_IMPL: ${LAPACK_IMPL}, LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}") + if("${LAPACK_IMPL}" STREQUAL "Apple") + set(CBLAS_H_PATH "Accelerate/Accelerate.h") + set(LAPACKE_H_PATH "Accelerate/Accelerate.h") + else() + _find_file_in_dirs(CBLAS_H_PATH "${LAPACK_CBLAS_H}" "${LAPACK_INCLUDE_DIR}") + _find_file_in_dirs(LAPACKE_H_PATH "${LAPACK_LAPACKE_H}" "${LAPACK_INCLUDE_DIR}") + endif() + if(NOT CBLAS_H_PATH OR NOT LAPACKE_H_PATH) + message(WARNING "CBLAS/LAPACK headers are not found in '${LAPACK_INCLUDE_DIR}'") + endif() + ocv_include_directories(${LAPACK_INCLUDE_DIR}) + list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES}) + set(HAVE_LAPACK 1) + + set(CBLAS_H_PROXY_PATH ${CMAKE_BINARY_DIR}/opencv_lapack.h) + set(_include_str "\#include \"${CBLAS_H_PATH}\"") + if("${CBLAS_H_PATH}" STREQUAL "${LAPACKE_H_PATH}") + else() + set(_include_str "${_include_str}\n\#include \"${LAPACKE_H_PATH}\"") + endif() + file(WRITE ${CBLAS_H_PROXY_PATH} ${_include_str}) + endif() +endif() diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index 82afd390ae..70b6cf543e 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -3,33 +3,29 @@ # ---------------------------------------------------------------------------- # --- Lapack --- -if(WITH_LAPACK) - if(WIN32) - set(BLA_STATIC 1) - endif() - find_package(LAPACK) - if(LAPACK_FOUND) - find_path(LAPACKE_INCLUDE_DIR "lapacke.h") - find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h") - if(LAPACKE_INCLUDE_DIR OR MKL_LAPACKE_INCLUDE_DIR) - find_path(CBLAS_INCLUDE_DIR "cblas.h") - find_path(MKL_CBLAS_INCLUDE_DIR "mkl_cblas.h") - - if(CBLAS_INCLUDE_DIR OR MKL_CBLAS_INCLUDE_DIR) - set(HAVE_LAPACK 1) - - if(CBLAS_INCLUDE_DIR) - ocv_include_directories(${LAPACKE_INCLUDE_DIR} ${CBLAS_INCLUDE_DIR}) - set(HAVE_LAPACK_GENERIC 1) - elseif(MKL_CBLAS_INCLUDE_DIR) - ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR} ${MKL_CBLAS_INCLUDE_DIR}) - set(HAVE_LAPACK_MKL 1) - endif() - list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES}) - endif() - endif() - endif() -endif() +# if(WITH_LAPACK) +# if(WIN32) +# set(BLA_STATIC 1) +# endif() +# find_package(LAPACK) +# if(LAPACK_FOUND) +# find_path(LAPACKE_INCLUDE_DIR "lapacke.h") +# find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h") +# if(LAPACKE_INCLUDE_DIR) +# ocv_include_directories(${LAPACKE_INCLUDE_DIR}) +# set(HAVE_LAPACK 1) +# set(HAVE_LAPACK_GENERIC 1) +# elseif(MKL_LAPACKE_INCLUDE_DIR) +# ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR}) +# set(HAVE_LAPACK 1) +# set(HAVE_LAPACK_MKL 1) +# elseif(APPLE) +# set(HAVE_LAPACK 1) +# set(HAVE_LAPACK_APPLE 1) +# endif() +# list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES}) +# endif() +# endif() # --- TBB --- if(WITH_TBB) diff --git a/cmake/OpenCVFindMKL.cmake b/cmake/OpenCVFindMKL.cmake new file mode 100644 index 0000000000..f43ce9c286 --- /dev/null +++ b/cmake/OpenCVFindMKL.cmake @@ -0,0 +1,136 @@ +# +# The script to detect Intel(R) Math Kernel Library (MKL) +# installation/package +# +# Parameters: +# MKL_WITH_TBB +# +# On return this will define: +# +# HAVE_MKL - True if Intel IPP found +# MKL_ROOT_DIR - root of IPP installation +# MKL_INCLUDE_DIRS - IPP include folder +# MKL_LIBRARIES - IPP libraries that are used by OpenCV +# + +macro (mkl_find_lib VAR NAME DIRS) + find_path(${VAR} ${NAME} ${DIRS} NO_DEFAULT_PATH) + set(${VAR} ${${VAR}}/${NAME}) + unset(${VAR} CACHE) +endmacro() + +macro(mkl_fail) + set(HAVE_MKL OFF CACHE BOOL "True if MKL found") + set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory") + unset(MKL_INCLUDE_DIRS CACHE) + unset(MKL_LIBRARIES CACHE) + return() +endmacro() + +macro(get_mkl_version VERSION_FILE) + # read MKL version info from file + file(STRINGS ${VERSION_FILE} STR1 REGEX "__INTEL_MKL__") + file(STRINGS ${VERSION_FILE} STR2 REGEX "__INTEL_MKL_MINOR__") + file(STRINGS ${VERSION_FILE} STR3 REGEX "__INTEL_MKL_UPDATE__") + #file(STRINGS ${VERSION_FILE} STR4 REGEX "INTEL_MKL_VERSION") + + # extract info and assign to variables + string(REGEX MATCHALL "[0-9]+" MKL_VERSION_MAJOR ${STR1}) + string(REGEX MATCHALL "[0-9]+" MKL_VERSION_MINOR ${STR2}) + string(REGEX MATCHALL "[0-9]+" MKL_VERSION_UPDATE ${STR3}) + set(MKL_VERSION_STR "${MKL_VERSION_MAJOR}.${MKL_VERSION_MINOR}.${MKL_VERSION_UPDATE}" CACHE STRING "MKL version" FORCE) +endmacro() + + +if(NOT DEFINED MKL_USE_MULTITHREAD) + OCV_OPTION(MKL_WITH_TBB "Use MKL with TBB multithreading" OFF)#ON IF WITH_TBB) + OCV_OPTION(MKL_WITH_OPENMP "Use MKL with OpenMP multithreading" OFF)#ON IF WITH_OPENMP) +endif() + +#check current MKL_ROOT_DIR +if(NOT MKL_ROOT_DIR OR NOT EXISTS ${MKL_ROOT_DIR}/include/mkl.h) + set(mkl_root_paths ${MKL_ROOT_DIR}) + if(DEFINED $ENV{MKLROOT}) + list(APPEND mkl_root_paths $ENV{MKLROOT}) + endif() + if(WIN32) + set(ProgramFilesx86 "ProgramFiles(x86)") + list(APPEND mkl_root_paths $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows/mkl) + endif() + if(UNIX) + list(APPEND mkl_root_paths "/opt/intel/mkl") + endif() + + find_path(MKL_ROOT_DIR include/mkl.h PATHS ${mkl_root_paths}) +endif() + +if(NOT MKL_ROOT_DIR) + mkl_fail() +endif() + +set(MKL_INCLUDE_DIRS ${MKL_ROOT_DIR}/include) +get_mkl_version(${MKL_INCLUDE_DIRS}/mkl_version.h) + +#determine arch +if(CMAKE_CXX_SIZEOF_DATA_PTR EQUAL 8) + set(MKL_X64 1) + set(MKL_ARCH "intel64") + + include(CheckTypeSize) + CHECK_TYPE_SIZE(int _sizeof_int) + if (_sizeof_int EQUAL 4) + set(MKL_LP64 "lp64") + else() + set(MKL_LP64 "ilp64") + endif() +else() + set(MKL_ARCH "ia32") +endif() + +if(${MKL_VERSION_STR} VERSION_GREATER "11.3.0" OR ${MKL_VERSION_STR} VERSION_EQUAL "11.3.0") + set(mkl_lib_find_paths + ${MKL_ROOT_DIR}/lib + ${MKL_ROOT_DIR}/lib/${MKL_ARCH} ${MKL_ROOT_DIR}/../tbb/lib/${MKL_ARCH}) + + set(mkl_lib_list + mkl_core + mkl_intel_${MKL_LP64}) + + if(MKL_WITH_TBB) + list(APPEND mkl_lib_list mkl_tbb_thread tbb) + elseif(MKL_WITH_OPENMP) + if(MSVC) + list(APPEND mkl_lib_list mkl_intel_thread libiomp5md) + else() + list(APPEND mkl_lib_list libmkl_gnu_thread) + endif() + else() + list(APPEND mkl_lib_list mkl_sequential) + endif() +else() + message(STATUS "MKL version ${MKL_VERSION_STR} is not supported") + mkl_fail() +endif() + + +set(MKL_LIBRARIES "") +foreach(lib ${mkl_lib_list}) + find_library(${lib} ${lib} ${mkl_lib_find_paths}) + mark_as_advanced(${lib}) + if(NOT ${lib}) + mkl_fail() + endif() + list(APPEND MKL_LIBRARIES ${${lib}}) +endforeach() + +message(STATUS "Found MKL ${MKL_VERSION_STR} at: ${MKL_ROOT_DIR}") +set(HAVE_MKL ON CACHE BOOL "True if MKL found") +set(MKL_ROOT_DIR ${MKL_ROOT_DIR} CACHE PATH "Path to MKL directory") +set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIRS} CACHE PATH "Path to MKL include directory") +if(NOT UNIX) + set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE FILEPATH "MKL libarries") +else() + #it's ugly but helps to avoid cyclic lib problem + set(MKL_LIBRARIES ${MKL_LIBRARIES} ${MKL_LIBRARIES} ${MKL_LIBRARIES} "-lpthread" "-lm" "-ldl") + set(MKL_LIBRARIES ${MKL_LIBRARIES} CACHE STRING "MKL libarries") +endif() \ No newline at end of file diff --git a/cmake/OpenCVFindOpenBLAS.cmake b/cmake/OpenCVFindOpenBLAS.cmake new file mode 100644 index 0000000000..60594dee46 --- /dev/null +++ b/cmake/OpenCVFindOpenBLAS.cmake @@ -0,0 +1,106 @@ +#COPYRIGHT +# +#All contributions by the University of California: +#Copyright (c) 2014, 2015, The Regents of the University of California (Regents) +#All rights reserved. +# +#All other contributions: +#Copyright (c) 2014, 2015, the respective contributors +#All rights reserved. +# +#Caffe uses a shared copyright model: each contributor holds copyright over +#their contributions to Caffe. The project versioning records all such +#contribution and copyright details. If a contributor wants to further mark +#their specific copyright on a particular contribution, they should indicate +#their copyright solely in the commit message of the change when it is +#committed. +# +#LICENSE +# +#Redistribution and use in source and binary forms, with or without +#modification, are permitted provided that the following conditions are met: +# +#1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +#2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +#CONTRIBUTION AGREEMENT +# +#By contributing to the BVLC/caffe repository through pull-request, comment, +#or otherwise, the contributor releases their content to the +#license and copyright terms herein. + +SET(Open_BLAS_INCLUDE_SEARCH_PATHS + /usr/include + /usr/include/openblas + /usr/include/openblas-base + /usr/local/include + /usr/local/include/openblas + /usr/local/include/openblas-base + /opt/OpenBLAS/include + $ENV{OpenBLAS_HOME} + $ENV{OpenBLAS_HOME}/include +) + +SET(Open_BLAS_LIB_SEARCH_PATHS + /lib/ + /lib/openblas-base + /lib64/ + /usr/lib + /usr/lib/openblas-base + /usr/lib64 + /usr/local/lib + /usr/local/lib64 + /opt/OpenBLAS/lib + $ENV{OpenBLAS}cd + $ENV{OpenBLAS}/lib + $ENV{OpenBLAS_HOME} + $ENV{OpenBLAS_HOME}/lib + ) + +FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS}) +FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS}) + +SET(OpenBLAS_FOUND ON) + +# Check include files +IF(NOT OpenBLAS_INCLUDE_DIR) + SET(OpenBLAS_FOUND OFF) + MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off") +ENDIF() + +# Check libraries +IF(NOT OpenBLAS_LIB) + SET(OpenBLAS_FOUND OFF) + MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off") +ENDIF() + +IF (OpenBLAS_FOUND) + IF (NOT OpenBLAS_FIND_QUIETLY) + MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}") + MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}") + ENDIF (NOT OpenBLAS_FIND_QUIETLY) +ELSE (OpenBLAS_FOUND) + IF (OpenBLAS_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find OpenBLAS") + ENDIF (OpenBLAS_FIND_REQUIRED) +ENDIF (OpenBLAS_FOUND) + +MARK_AS_ADVANCED( + OpenBLAS_INCLUDE_DIR + OpenBLAS_LIB + OpenBLAS +) \ No newline at end of file diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index 514d1f5c70..05add9e2c5 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -198,12 +198,6 @@ /* Lapack */ #cmakedefine HAVE_LAPACK -/* Lapack Generic */ -#cmakedefine HAVE_LAPACK_GENERIC - -/* Lapack MKL */ -#cmakedefine HAVE_LAPACK_MKL - /* FP16 */ #cmakedefine HAVE_FP16 diff --git a/modules/core/src/hal_internal.cpp b/modules/core/src/hal_internal.cpp index 0c6b7c01f8..b2b6dc3626 100644 --- a/modules/core/src/hal_internal.cpp +++ b/modules/core/src/hal_internal.cpp @@ -46,15 +46,7 @@ #ifdef HAVE_LAPACK -#ifdef HAVE_LAPACK_MKL - #include - #include -#endif - -#ifdef HAVE_LAPACK_GENERIC - #include - #include -#endif +#include "opencv_lapack.h" #include #include