Skip to content

Commit c0ff1c3

Browse files
author
me
committed
just use FindBLAS if MKL is not found
1 parent 0078cb4 commit c0ff1c3

File tree

1 file changed

+16
-54
lines changed

1 file changed

+16
-54
lines changed

dlib/cmake_utils/find_blas.cmake

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
include(CheckTypeSize)
2525
include(CheckFunctionExists)
26-
include(CheckLibraryExists)
27-
include(CheckFortranFunctionExists)
28-
find_package(PkgConfig)
2926

3027
# setting this makes CMake allow normal looking if else statements (TODO: check if this is still necessary)
3128
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
@@ -187,57 +184,22 @@ if (mkl_seq_found OR mkl_tbb_found OR mkl_thread_found)
187184
return()
188185
endif()
189186

190-
# Search for BLAS - pkgconfig
191-
if (PKG_CONFIG_FOUND)
192-
pkg_check_modules(BLAS_REFERENCE IMPORTED_TARGET GLOBAL blas)
193-
pkg_check_modules(LAPACK_REFERENCE IMPORTED_TARGET GLOBAL lapack)
194-
195-
# Make sure the cblas found by pkgconfig actually has cblas symbols.
196-
set(CMAKE_REQUIRED_LIBRARIES "${BLAS_REFERENCE_LDFLAGS}")
197-
check_function_exists(cblas_ddot PKGCFG_HAVE_CBLAS)
198-
199-
if (BLAS_REFERENCE_FOUND AND LAPACK_REFERENCE_FOUND AND PKGCFG_HAVE_CBLAS)
200-
message(STATUS "Found BLAS and LAPACK via pkg-config")
201-
set(blas_found 1)
202-
set(lapack_found 1)
203-
set(blas_libraries ${BLAS_REFERENCE_LDFLAGS})
204-
set(lapack_libraries ${LAPACK_REFERENCE_LDFLAGS})
205-
return()
206-
endif()
187+
# Search for BLAS - FindBLAS
188+
set(BLA_PREFER_PKGCONFIG 1)
189+
find_package(BLAS)
190+
191+
if (BLAS_FOUND)
192+
message(STATUS "Found BLAS library")
193+
set(blas_found 1)
194+
set(blas_libraries ${BLAS_LIBRARIES})
207195
endif()
208196

209-
# Search for BLAS - openblas
210-
if (NOT blas_found)
211-
set(extra_paths
212-
/usr/lib64
213-
/usr/lib64/atlas-sse3
214-
/usr/lib64/atlas-sse2
215-
/usr/lib64/atlas
216-
/usr/lib
217-
/usr/lib/atlas-sse3
218-
/usr/lib/atlas-sse2
219-
/usr/lib/atlas
220-
/usr/lib/openblas-base
221-
/opt/OpenBLAS/lib
222-
$ENV{OPENBLAS_HOME}/lib)
223-
224-
find_library(cblas_lib NAMES openblasp openblas PATHS ${extra_paths})
225-
mark_as_advanced(cblas_lib)
226-
227-
if (cblas_lib)
228-
message(STATUS "Found OpenBLAS library")
229-
set(blas_found 1)
230-
set(blas_libraries ${cblas_lib})
231-
232-
# If you compiled OpenBLAS with LAPACK in it then it should have the
233-
# sgetrf_single function in it. So if we find that function in
234-
# OpenBLAS then just use OpenBLAS's LAPACK.
235-
set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
236-
check_function_exists(sgetrf_single OPENBLAS_HAS_LAPACK)
237-
238-
if (OPENBLAS_HAS_LAPACK)
239-
message(STATUS "Using OpenBLAS's built in LAPACK")
240-
set(lapack_found 1)
241-
endif()
242-
endif()
197+
# Search for LAPACK - FindLAPACK
198+
set(BLA_PREFER_PKGCONFIG 1)
199+
find_package(LAPACK)
200+
201+
if (LAPACK_FOUND)
202+
message(STATUS "Found LAPACK library")
203+
set(lapack_found 1)
204+
set(lapack_libraries ${LAPACK_LIBRARIES})
243205
endif()

0 commit comments

Comments
 (0)