Skip to content

Commit 780d767

Browse files
authored
CMake: update BLAS detection (#2318)
* Search for 64bit BLAS if supported by CMake. * On apple, try accelerate if nothing else was specified. Use the new interface (https://developer.apple.com/documentation/accelerate/blas). Fixes #2286.
1 parent bd915ad commit 780d767

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

CMakeLists.txt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,35 @@ if(${BLAS} STREQUAL "MKL" OR DEFINED ENV{MKLROOT})
169169
-lmkl
170170
CACHE STRING "")
171171
endif()
172-
elseif(NOT DEFINED ENV{BLAS_LIBS} AND NOT DEFINED ENV{BLAS_CFLAGS})
172+
elseif(
173+
NOT DEFINED ENV{BLAS_LIBS}
174+
AND NOT DEFINED ENV{BLAS_CFLAGS}
175+
AND NOT BLAS_FOUND)
173176
# if nothing is specified via environment variables, let's try FindBLAS
174-
find_package(BLAS)
177+
if($(CMAKE_VERSION) VERSION_GREATER_EQUAL 3.22)
178+
set(BLA_SIZEOF_INTEGER 8)
179+
endif()
180+
181+
if(APPLE AND (NOT DEFINED BLA_VENDOR OR BLA_VENDOR STREQUAL "All"))
182+
set(BLA_VENDOR Apple)
183+
find_package(BLAS)
184+
if(BLAS_FOUND)
185+
set_property(
186+
TARGET BLAS::BLAS
187+
APPEND
188+
PROPERTY INTERFACE_COMPILE_DEFINITIONS ACCELERATE_NEW_LAPACK)
189+
set_property(
190+
TARGET BLAS::BLAS
191+
APPEND
192+
PROPERTY INTERFACE_COMPILE_DEFINITIONS ACCELERATE_LAPACK_ILP64)
193+
else()
194+
set(BLA_VENDOR "All")
195+
endif()
196+
197+
endif()
198+
if(NOT BLAS_FOUND)
199+
find_package(BLAS)
200+
endif()
175201
if(NOT BLAS_FOUND)
176202
# Nothing specified by the user and FindBLAS didn't find anything; let's try
177203
# if cblas is available on the system paths.

0 commit comments

Comments
 (0)