Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 5783414

Browse files
authored
Update FindSystemBLAS cmake (#509)
1 parent eff2458 commit 5783414

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

cmake/Modules/FindSystemBLAS.cmake

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#/***************************************************************************
32
# *
43
# * @license
@@ -23,27 +22,40 @@
2322
# * @filename FindSystemBLAS.cmake
2423
# *
2524
# **************************************************************************/
26-
set(SystemBLAS_FOUND FALSE)
27-
2825
include(FindPackageHandleStandardArgs)
2926

30-
find_library(OPENBLAS_LIBRARIES NAMES openblas libopenblas)
31-
find_path(OPENBLAS_INCLUDE_DIRS openblas_config.h)
32-
if(OPENBLAS_LIBRARIES AND OPENBLAS_INCLUDE_DIRS)
27+
# Let user possibility to set blas path to similar libraries like lapack
28+
if(BLAS_LIBRARIES AND BLAS_INCLUDE_DIRS)
3329
find_package(Threads REQUIRED)
3430
add_library(blas::blas UNKNOWN IMPORTED)
3531
set_target_properties(blas::blas PROPERTIES
36-
INTERFACE_INCLUDE_DIRECTORIES "${OPENBLAS_INCLUDE_DIRS}"
32+
INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}"
3733
INTERFACE_LINK_LIBRARIES Threads::Threads
38-
IMPORTED_LOCATION "${OPENBLAS_LIBRARIES}"
34+
IMPORTED_LOCATION "${BLAS_LIBRARIES}"
3935
)
40-
set(OPENBLAS_FOUND TRUE)
41-
set(SystemBLAS_LIBRARIES OPENBLAS_LIBRARIES)
36+
set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES})
4237
else()
38+
set(BLA_VENDOR OpenBLAS)
4339
find_package(BLAS QUIET)
40+
if(BLAS_FOUND)
41+
set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES})
42+
endif()
43+
if(NOT BLAS_FOUND)
44+
message(WARNING "openBLAS library was not found on your system")
45+
unset(BLA_VENDOR)
46+
set(BLA_VENDOR All)
47+
find_package(BLAS QUIET)
48+
if (BLAS_FOUND)
49+
message(WARNING "Found another BLAS library on your system. Not using openBLAS may cause some tests to fail.")
50+
message("-- BLAS library found at ${BLAS_LIBRARIES}")
51+
set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES})
52+
endif()
53+
endif()
54+
4455
if(NOT BLAS_FOUND)
4556
set(BLA_STATIC ON)
4657
find_package(BLAS QUIET)
58+
set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES})
4759
endif()
4860

4961
if(BLAS_FOUND AND NOT TARGET blas::blas)
@@ -53,12 +65,7 @@ else()
5365
)
5466
endif()
5567

56-
if(BLAS_FOUND)
57-
set(SystemBLAS_FOUND TRUE)
58-
set(SystemBLAS_LIBRARIES BLAS_LIBRARIES)
59-
endif()
6068
endif()
6169

6270
find_package_handle_standard_args(SystemBLAS
63-
FOUND_VAR SystemBLAS_FOUND
6471
REQUIRED_VARS SystemBLAS_LIBRARIES)

0 commit comments

Comments
 (0)