From 2eece9f79186c353e9f23f08faeb51f233e4cf10 Mon Sep 17 00:00:00 2001 From: nscipione Date: Wed, 3 Apr 2024 17:49:38 +0200 Subject: [PATCH 1/3] Update FindSystemBLAS cmake Update how BLAS library is found and set. Provide better message to users if openBLAS is not found. Clearly states that openBLAS is the library used for testing. Signed-off-by: nscipione --- cmake/Modules/FindSystemBLAS.cmake | 38 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/cmake/Modules/FindSystemBLAS.cmake b/cmake/Modules/FindSystemBLAS.cmake index aa95b731e..f41a6e941 100644 --- a/cmake/Modules/FindSystemBLAS.cmake +++ b/cmake/Modules/FindSystemBLAS.cmake @@ -1,4 +1,3 @@ - #/*************************************************************************** # * # * @license @@ -27,23 +26,42 @@ set(SystemBLAS_FOUND FALSE) include(FindPackageHandleStandardArgs) -find_library(OPENBLAS_LIBRARIES NAMES openblas libopenblas) -find_path(OPENBLAS_INCLUDE_DIRS openblas_config.h) -if(OPENBLAS_LIBRARIES AND OPENBLAS_INCLUDE_DIRS) +# Let user possibility to set blas path to similar libraries like lapack +if(BLAS_LIBRARIES AND BLAS_INCLUDE_DIRS) find_package(Threads REQUIRED) add_library(blas::blas UNKNOWN IMPORTED) set_target_properties(blas::blas PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENBLAS_INCLUDE_DIRS}" + INTERFACE_INCLUDE_DIRECTORIES "${BLAS_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES Threads::Threads - IMPORTED_LOCATION "${OPENBLAS_LIBRARIES}" + IMPORTED_LOCATION "${BLAS_LIBRARIES}" ) - set(OPENBLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES OPENBLAS_LIBRARIES) + set(BLAS_FOUND TRUE) + set(SystemBLAS_LIBRARIES USER_DEFINED) else() + set(BLA_VENDOR OpenBLAS) find_package(BLAS QUIET) + if(BLAS_FOUND) + set(OPENBLAS_FOUND TRUE) + set(SystemBLAS_LIBRARIES OPENBLAS_LIBRARIES) + endif() + if(NOT BLAS_FOUND) + message(WARNING "openBLAS library was not found on your system") + unset(BLA_VENDOR) + set(BLA_VENDOR All) + find_package(BLAS QUIET) + if (BLAS_FOUND) + message(WARNING "Found another BLAS library on your system. Not using openBLAS may cause some tests to fail.") + message("-- BLAS library found at ${BLAS_LIBRARIES}") + set(SystemBLAS_FOUND TRUE) + set(SystemBLAS_LIBRARIES BLAS_LIBRARIES) + endif() + endif() + if(NOT BLAS_FOUND) set(BLA_STATIC ON) find_package(BLAS QUIET) + set(SystemBLAS_FOUND TRUE) + set(SystemBLAS_LIBRARIES BLAS_LIBRARIES) endif() if(BLAS_FOUND AND NOT TARGET blas::blas) @@ -53,10 +71,6 @@ else() ) endif() - if(BLAS_FOUND) - set(SystemBLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES BLAS_LIBRARIES) - endif() endif() find_package_handle_standard_args(SystemBLAS From 268ff137a87061fe65e3760b823ed32eacc7a38c Mon Sep 17 00:00:00 2001 From: nscipione Date: Mon, 8 Apr 2024 09:02:43 +0100 Subject: [PATCH 2/3] Update message in cmake when a BLAS Library is set & minor fixes. The configuration used to print a generic type of library, change that to message to print library location. Plus minor adjustements. Signed-off-by: nscipione --- cmake/Modules/FindSystemBLAS.cmake | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/FindSystemBLAS.cmake b/cmake/Modules/FindSystemBLAS.cmake index f41a6e941..43f7cb6cc 100644 --- a/cmake/Modules/FindSystemBLAS.cmake +++ b/cmake/Modules/FindSystemBLAS.cmake @@ -35,33 +35,29 @@ if(BLAS_LIBRARIES AND BLAS_INCLUDE_DIRS) INTERFACE_LINK_LIBRARIES Threads::Threads IMPORTED_LOCATION "${BLAS_LIBRARIES}" ) - set(BLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES USER_DEFINED) + set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES}) else() set(BLA_VENDOR OpenBLAS) find_package(BLAS QUIET) if(BLAS_FOUND) - set(OPENBLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES OPENBLAS_LIBRARIES) + set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES}) endif() if(NOT BLAS_FOUND) - message(WARNING "openBLAS library was not found on your system") + message(WARNING "openBLAS library was not found on your system") unset(BLA_VENDOR) set(BLA_VENDOR All) find_package(BLAS QUIET) if (BLAS_FOUND) message(WARNING "Found another BLAS library on your system. Not using openBLAS may cause some tests to fail.") message("-- BLAS library found at ${BLAS_LIBRARIES}") - set(SystemBLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES BLAS_LIBRARIES) + set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES}) endif() endif() if(NOT BLAS_FOUND) set(BLA_STATIC ON) find_package(BLAS QUIET) - set(SystemBLAS_FOUND TRUE) - set(SystemBLAS_LIBRARIES BLAS_LIBRARIES) + set(SystemBLAS_LIBRARIES ${BLAS_LIBRARIES}) endif() if(BLAS_FOUND AND NOT TARGET blas::blas) From 08d78b42ca378d9b6c959840c53ce246ca9668b9 Mon Sep 17 00:00:00 2001 From: nscipione Date: Mon, 8 Apr 2024 10:24:05 +0100 Subject: [PATCH 3/3] Completely remove SystemBLAS_FOUND variable and FOUND_VAR Signed-off-by: nscipione --- cmake/Modules/FindSystemBLAS.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/Modules/FindSystemBLAS.cmake b/cmake/Modules/FindSystemBLAS.cmake index 43f7cb6cc..78830fa00 100644 --- a/cmake/Modules/FindSystemBLAS.cmake +++ b/cmake/Modules/FindSystemBLAS.cmake @@ -22,8 +22,6 @@ # * @filename FindSystemBLAS.cmake # * # **************************************************************************/ -set(SystemBLAS_FOUND FALSE) - include(FindPackageHandleStandardArgs) # Let user possibility to set blas path to similar libraries like lapack @@ -70,5 +68,4 @@ else() endif() find_package_handle_standard_args(SystemBLAS - FOUND_VAR SystemBLAS_FOUND REQUIRED_VARS SystemBLAS_LIBRARIES)