@@ -7,30 +7,49 @@ if (WIN32)
77 message (STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR} " )
88elseif (NOT APPLE )
99 # LINUX
10- find_library (OPENBLAS_LIB
11- NAMES openblas
12- HINTS "${BLAS_ROOT} /lib" )
13-
14- if (OPENBLAS_LIB)
15- message ("Found OpenBLAS library at ${OPENBLAS_LIB} " )
16-
17- else (OPENBLAS_LIB)
18- find_library (BLAS_LIB
19- NAMES blas HINTS
20- "${BLAS_ROOT} /lib" )
21-
22- if (NOT BLAS_LIB)
23- message (FATAL_ERROR "No BLAS library found" )
24- endif (NOT BLAS_LIB)
25- message ("Found BLAS library at ${BLAS_LIB} " )
26- endif (OPENBLAS_LIB)
10+
11+ # If a BLAS install was specified try to use it first.
12+ if (NOT (BLAS_ROOT STREQUAL "" ))
13+ message (STATUS "Looking for blas CMake targets file in " ${BLAS_ROOT} )
14+ find_package (OpenBLAS CONFIG NO_DEFAULT_PATH)
15+ else ()
16+ find_package (OpenBLAS CONFIG)
17+ endif ()
18+
19+ if (OpenBLAS_FOUND)
20+ message (STATUS "OpenBLAS CMake config path: ${OpenBLAS_DIR} " )
21+ else ()
22+ find_library (OPENBLAS_LIB
23+ NAMES openblas
24+ HINTS "${BLAS_ROOT} /lib" )
25+
26+ if (OPENBLAS_LIB)
27+ message ("Found OpenBLAS library at ${OPENBLAS_LIB} " )
28+ else ()
29+ find_library (BLAS_LIB
30+ NAMES blas HINTS
31+ "${BLAS_ROOT} /lib" )
32+
33+ if (BLAS_LIB)
34+ message ("Found BLAS library at ${BLAS_LIB} " )
35+ else ()
36+ message (FATAL_ERROR "No BLAS library found" )
37+ endif ()
38+ endif ()
39+ endif ()
2740endif ()
2841
2942# METIS
3043set (METIS_ROOT "" CACHE STRING "Root directory of METIS" )
3144message (STATUS "METIS_ROOT is " ${METIS_ROOT} )
3245
33- find_package (metis CONFIG)
46+ # If a METIS install was specified try to use it first.
47+ if (NOT (METIS_ROOT STREQUAL "" ))
48+ message (STATUS "Looking for METIS CMake targets file in " ${METIS_ROOT} )
49+ find_package (metis CONFIG NO_DEFAULT_PATH)
50+ else ()
51+ find_package (metis CONFIG)
52+ endif ()
3453
3554if (metis_FOUND)
3655 message (STATUS "metis CMake config path: ${metis_DIR} " )
@@ -49,15 +68,29 @@ else()
4968 PATHS "${METIS_ROOT} /lib" "${METIS_ROOT} /bin"
5069 NO_DEFAULT_PATH)
5170
52- message ("Found Metis library at ${METIS_LIB} " )
71+ if (METIS_LIB)
72+ message ("Found Metis library at ${METIS_LIB} " )
73+ else ()
74+ # METIS_ROOT was not successful
75+ message ("Metis not found in METIS_PATH, fallback to default search." )
76+ if (NOT (METIS_ROOT STREQUAL "" ))
77+ find_package (metis CONFIG)
78+
79+ if (metis_FOUND)
80+ message (STATUS "metis CMake config path: ${metis_DIR} " )
81+ else ()
82+ message (FATAL_ERROR "No Metis library found" )
83+ endif ()
84+ endif ()
85+ endif ()
5386endif ()
5487
5588# GKlib optional for newer versions on ubuntu and macos
5689set (GKLIB_ROOT "" CACHE STRING "Root directory of GKlib" )
5790if (NOT (GKLIB_ROOT STREQUAL "" ))
5891 message (STATUS "GKLIB_ROOT is " ${GKLIB_ROOT} )
5992
60- find_package (GKlib CONFIG)
93+ find_package (GKlib CONFIG NO_DEFAILT_PATH )
6194
6295 if (GKlib_FOUND)
6396 message (STATUS "gklib CMake config path: ${GKlib_DIR} " )
@@ -91,6 +124,18 @@ if (NOT (GKLIB_ROOT STREQUAL ""))
91124 PATHS "${GKLIB_ROOT} /lib"
92125 NO_DEFAULT_PATH)
93126
94- message ("Found GKlib library at ${GKLIB_LIB} " )
127+ if (GKLIB_LIB)
128+ message ("Found GKlib library at ${GKLIB_LIB} " )
129+ else ()
130+ # GKLIB_ROOT was not successful
131+ message ("GKlib not found in GKLIB_PATH, fallback to default search." )
132+ find_package (GKlib CONFIG)
133+
134+ if (GKlib_FOUND)
135+ message (STATUS "GKlib CMake config path: ${GKlib_DIR} " )
136+ else ()
137+ message (FATAL_ERROR "No GKLib library found" )
138+ endif ()
139+ endif ()
95140 endif ()
96141endif ()
0 commit comments