Skip to content

Commit

Permalink
CMake: update BLAS detection (#2318)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
dweindl authored Feb 26, 2024
1 parent bd915ad commit 780d767
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,35 @@ if(${BLAS} STREQUAL "MKL" OR DEFINED ENV{MKLROOT})
-lmkl
CACHE STRING "")
endif()
elseif(NOT DEFINED ENV{BLAS_LIBS} AND NOT DEFINED ENV{BLAS_CFLAGS})
elseif(
NOT DEFINED ENV{BLAS_LIBS}
AND NOT DEFINED ENV{BLAS_CFLAGS}
AND NOT BLAS_FOUND)
# if nothing is specified via environment variables, let's try FindBLAS
find_package(BLAS)
if($(CMAKE_VERSION) VERSION_GREATER_EQUAL 3.22)
set(BLA_SIZEOF_INTEGER 8)
endif()

if(APPLE AND (NOT DEFINED BLA_VENDOR OR BLA_VENDOR STREQUAL "All"))
set(BLA_VENDOR Apple)
find_package(BLAS)
if(BLAS_FOUND)
set_property(
TARGET BLAS::BLAS
APPEND
PROPERTY INTERFACE_COMPILE_DEFINITIONS ACCELERATE_NEW_LAPACK)
set_property(
TARGET BLAS::BLAS
APPEND
PROPERTY INTERFACE_COMPILE_DEFINITIONS ACCELERATE_LAPACK_ILP64)
else()
set(BLA_VENDOR "All")
endif()

endif()
if(NOT BLAS_FOUND)
find_package(BLAS)
endif()
if(NOT BLAS_FOUND)
# Nothing specified by the user and FindBLAS didn't find anything; let's try
# if cblas is available on the system paths.
Expand Down

0 comments on commit 780d767

Please sign in to comment.