Skip to content

Commit 9b5a638

Browse files
authored
Update FindLAPACK.cmake
1 parent 9b61d38 commit 9b5a638

File tree

1 file changed

+30
-29
lines changed

1 file changed

+30
-29
lines changed

toolchain/cmake/regular/FindLAPACK.cmake

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,35 @@
55

66
include(FindPackageHandleStandardArgs)
77

8-
# Special handling for Cray systems which have optimized math libraries
9-
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
10-
# On Cray systems, LAPACK is typically provided by the cray-libsci package
11-
find_library(LAPACK_LIBRARY
12-
NAMES sci_cray sci_gnu sci_intel sci_pgi sci
13-
NAMES_PER_DIR
14-
)
15-
set(BLAS_LIBRARY "") # BLAS is included in the sci library
16-
else()
17-
# Find LAPACK library for other compilers
18-
find_library(LAPACK_LIBRARY
19-
NAMES lapack
20-
PATH_SUFFIXES lapack
21-
NAMES_PER_DIR
22-
)
23-
24-
# Find BLAS library (required by LAPACK)
25-
find_library(BLAS_LIBRARY
26-
NAMES blas openblas
27-
PATH_SUFFIXES blas
28-
NAMES_PER_DIR
29-
)
30-
31-
# Some LAPACK implementations include BLAS
32-
if (NOT BLAS_LIBRARY)
33-
set(BLAS_LIBRARY "")
34-
endif()
35-
endif()
8+
# First, try to find a custom-built LAPACK (e.g., from ExternalProject)
9+
# This will be in CMAKE_PREFIX_PATH or CMAKE_FIND_ROOT_PATH
10+
find_library(LAPACK_LIBRARY
11+
NAMES lapack
12+
PATH_SUFFIXES lib lib64 lapack
13+
NAMES_PER_DIR
14+
)
15+
16+
# Find BLAS library (required by LAPACK for non-Cray systems)
17+
find_library(BLAS_LIBRARY
18+
NAMES blas openblas
19+
PATH_SUFFIXES lib lib64 blas
20+
NAMES_PER_DIR
21+
)
22+
23+
# Special handling for Cray systems which have optimized math libraries
24+
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray" AND NOT LAPACK_LIBRARY)
25+
# On Cray systems, LAPACK is typically provided by the cray-libsci package
26+
find_library(LAPACK_LIBRARY
27+
NAMES sci_cray sci_gnu sci_intel sci_pgi sci
28+
NAMES_PER_DIR
29+
)
30+
set(BLAS_LIBRARY "") # BLAS is included in the sci library
31+
endif()
32+
33+
# Some LAPACK implementations include BLAS
34+
if (NOT BLAS_LIBRARY)
35+
set(BLAS_LIBRARY "")
36+
endif()
3637

3738
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
3839
LAPACK
@@ -57,4 +58,4 @@
5758
set_property(TARGET LAPACK::LAPACK APPEND PROPERTY
5859
INTERFACE_LINK_LIBRARIES "m")
5960
endif()
60-
endif()
61+
endif()

0 commit comments

Comments
 (0)