From 5be00636654ac41b8263091debe87c60385c6c88 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Tue, 16 Jan 2024 16:37:32 +0100 Subject: [PATCH] cmake: allow more generic OpenBLAS linkage First search for OpenBLAS-config.cmake file, and afterwards use the CMake provided `FindBLAS` module. This allows usage with Ubuntu OpenBLAS system packages as well as Hunter/user provided OpenBLAS install directory. --- CHANGELOG.md | 3 +++ CMakeLists.txt | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2b5c608..419176e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Unreleased +# unreleased +- More generic `OpenBLAS` linkage [#122](https://github.com/jlblancoc/suitesparse-metis-for-windows/pull/122) + # Release 1.8.0: October 25th, 2023 - Increase minimum required CMake version to v3.5 to prevent deprecation warnings [#117](https://github.com/jlblancoc/suitesparse-metis-for-windows/issues/117). - Add option `METIS_IDXTYPEWIDTH` with default `64` to override the index type used for `metis.h` [#116](https://github.com/jlblancoc/suitesparse-metis-for-windows/issues/116). diff --git a/CMakeLists.txt b/CMakeLists.txt index 15f54985..e92d04ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,10 +267,22 @@ if (WITH_OPENBLAS) # mabye with 'NOFORTAN=1' to get a pure C++ OpenBLAS library (with the # benefits described above) hunter_add_package(OpenBLAS) - find_package(OpenBLAS CONFIG REQUIRED) - message(STATUS "found OpenBLAS config file. Linking target OpenBLAS::OpenBLAS") - set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS OpenBLAS::OpenBLAS) set(BLA_VENDOR OpenBLAS) + find_package(OpenBLAS CONFIG) + if (OpenBLAS_FOUND) + message(STATUS "Found OpenBLAS ${OpenBLAS_VERSION}") + else() + message(STATUS "Looking for OpenBLAS") + find_package(BLAS REQUIRED) + message(STATUS "Found OpenBLAS in ${BLAS_LIBRARIES}") + endif() + if (TARGET OpenBLAS::OpenBLAS) + message(STATUS "found OpenBLAS config file, linking target OpenBLAS::OpenBLAS") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS OpenBLAS::OpenBLAS) + else() + message(STATUS "found OpenBLAS, linking target BLAS::BLAS") + set(SuiteSparse_LINKER_LAPACK_BLAS_LIBS BLAS::BLAS) + endif() elseif (WITH_MKL) hunter_add_package(mkl) set(BLA_VENDOR "Intel10_64lp")