Skip to content

Commit 450d19f

Browse files
committed
MAINT: Try a much simpler BLAS handling check
1 parent b1573aa commit 450d19f

File tree

1 file changed

+17
-41
lines changed

1 file changed

+17
-41
lines changed

meson.build

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,25 @@ print(incdir)
2121
'''], check: true).stdout().strip()
2222

2323
# Get BLAS
24-
blas_deps = []
25-
if get_option('link_mkl')
26-
blas_deps = [cc.find_library('mkl_rt', required : false)]
27-
if not blas_deps[0].found()
28-
blas_deps = [dependency('mkl-sdl', required : false)]
29-
endif
24+
blas_dep = dependency('', required: false)
25+
if host_machine.system() == 'darwin'
26+
message('Host is macOS, attempting to link with Accelerate framework...')
27+
blas_dep = dependency('accelerate')
3028
else
31-
if host_machine.system() == 'darwin'
32-
blas_deps = [dependency('Accelerate')]
33-
else
34-
blas_deps = [cc.find_library('openblas', static: get_option('link_blas_statically'), required : false)]
35-
if not blas_deps[0].found()
36-
blas_deps = [dependency(['openblas', 'OpenBLAS'], static: get_option('link_blas_statically'), required : false)]
37-
endif
38-
endif
39-
40-
# try to find blas/cblas (e.g., Linux)
41-
if not blas_deps[0].found()
42-
blas_deps = [cc.find_library('blas', static: get_option('link_blas_statically'), required : false)]
43-
if not blas_deps[0].found()
44-
blas_deps = [dependency('blas', static: get_option('link_blas_statically'), required : false)]
45-
endif
46-
lapack_dep = cc.find_library('lapack', static: get_option('link_blas_statically'), required : false)
47-
if not lapack_dep.found()
48-
lapack_dep = dependency('lapack', static: get_option('link_blas_statically'), required : false)
49-
endif
50-
if lapack_dep.found()
51-
blas_deps += lapack_dep
52-
endif
53-
cblas_dep = cc.find_library('cblas', static: get_option('link_blas_statically'), required : false)
54-
if not cblas_dep.found()
55-
cblas_dep = dependency('cblas', static: get_option('link_blas_statically'), required : false)
56-
endif
57-
if cblas_dep.found()
58-
blas_deps += cblas_dep
59-
endif
60-
endif
29+
message('Searching for a BLAS/LAPACK implementation (OpenBLAS, MKL, etc.)...')
30+
# This will find the MKL-backed openblas from Conda when link_mkl is true,
31+
# or the system's OpenBLAS otherwise.
32+
blas_dep = dependency('blas', static: get_option('link_blas_statically'), required: false)
33+
endif
34+
35+
# Final check
36+
if not blas_dep.found() and not get_option('sdist_mode')
37+
error('A required BLAS/LAPACK implementation (MKL, Accelerate, or OpenBLAS) was not found.')
6138
endif
6239

63-
# Since nothing above was required, we stop here if failed.
64-
# When creating an sdist we are not compiling / linking, so don't need to fail.
65-
if not blas_deps[0].found() and not get_option('sdist_mode')
66-
error('OpenBLAS or Netlib BLAS/CBLAS is required on all platforms, and was not found.')
40+
# Sanity check
41+
if get_option('link_mkl') and not ('mkl' in blas_dep.name() or blas_dep.name().to_lower() == 'accelerate')
42+
error('Requested MKL but was not found in library')
6743
endif
6844

6945
# Common
@@ -76,7 +52,7 @@ common_includes = [
7652
'scs_source/linsys',
7753
incdir_numpy
7854
]
79-
_deps = [blas_deps]
55+
_deps = [blas_dep]
8056
if get_option('use_openmp')
8157
_deps += dependency('openmp')
8258
endif

0 commit comments

Comments
 (0)