From e38d864664fe21513e90e7425f21456bc7f10086 Mon Sep 17 00:00:00 2001 From: scivision Date: Fri, 24 May 2024 15:24:58 -0400 Subject: [PATCH] more conservative use of ENV{MKLROOT} --- CMakeLists.txt | 2 +- cmake/FindLAPACK.cmake | 3 ++- cmake/FindSCALAPACK.cmake | 2 +- cmake/config.cmake.in | 9 +++++---- cmake/lapack.cmake | 2 +- cmake/scalapack.cmake | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5759a1..7b26351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ find_package(Threads) if(parallel) find_package(MPI COMPONENTS C Fortran REQUIRED) - if(NOT DEFINED ENV{MKLROOT} OR NOT scalapack) + if(NOT DEFINED ENV{MKLROOT} AND NOT LAPACK_VENDOR MATCHES "^MKL" OR NOT scalapack) # oneMKL MKLConfig.cmake must be invoked only once include(cmake/lapack.cmake) endif() diff --git a/cmake/FindLAPACK.cmake b/cmake/FindLAPACK.cmake index 136c16d..8647696 100644 --- a/cmake/FindLAPACK.cmake +++ b/cmake/FindLAPACK.cmake @@ -364,8 +364,9 @@ if(NOT (lapack_cray OR Netlib IN_LIST LAPACK_FIND_COMPONENTS OR Atlas IN_LIST LAPACK_FIND_COMPONENTS OR MKL IN_LIST LAPACK_FIND_COMPONENTS + OR MKL64 IN_LIST LAPACK_FIND_COMPONENTS OR AOCL IN_LIST LAPACK_FIND_COMPONENTS)) - if(DEFINED ENV{MKLROOT}) + if(DEFINED ENV{MKLROOT} AND IS_DIRECTORY "$ENV{MKLROOT}") list(APPEND LAPACK_FIND_COMPONENTS MKL) else() list(APPEND LAPACK_FIND_COMPONENTS Netlib) diff --git a/cmake/FindSCALAPACK.cmake b/cmake/FindSCALAPACK.cmake index 56d7d9c..f8c4cdc 100644 --- a/cmake/FindSCALAPACK.cmake +++ b/cmake/FindSCALAPACK.cmake @@ -194,7 +194,7 @@ if(DEFINED ENV{CRAYPE_VERSION}) endif() if(NOT scalapack_cray) - if(NOT MKL IN_LIST SCALAPACK_FIND_COMPONENTS AND DEFINED ENV{MKLROOT}) + if(NOT MKL IN_LIST SCALAPACK_FIND_COMPONENTS AND DEFINED ENV{MKLROOT} AND IS_DIRECTORY "$ENV{MKLROOT}") list(APPEND SCALAPACK_FIND_COMPONENTS MKL) endif() endif() diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index 75aad60..370de9e 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -16,12 +16,13 @@ set(MUMPS_d_FOUND @BUILD_DOUBLE@) set(MUMPS_c_FOUND @BUILD_COMPLEX@) set(MUMPS_z_FOUND @BUILD_COMPLEX16@) -if(NOT DEFINED ENV{MKLROOT}) - find_dependency(LAPACK COMPONENTS ${MUMPS_LAPACK_VENDOR}) -endif() - if(MUMPS_parallel) find_dependency(MPI COMPONENTS C Fortran) + + if(NOT MUMPS_LAPACK_VENDOR MATCHES "^MKL") + find_dependency(LAPACK COMPONENTS ${MUMPS_LAPACK_VENDOR}) + endif() + find_dependency(SCALAPACK) else() find_dependency(LAPACK COMPONENTS ${MUMPS_LAPACK_VENDOR}) diff --git a/cmake/lapack.cmake b/cmake/lapack.cmake index 374e8ed..3f0997e 100644 --- a/cmake/lapack.cmake +++ b/cmake/lapack.cmake @@ -1,6 +1,6 @@ # Handle options for finding LAPACK -if(NOT DEFINED LAPACK_VENDOR AND DEFINED ENV{MKLROOT}) +if(NOT DEFINED LAPACK_VENDOR AND DEFINED ENV{MKLROOT} AND IS_DIRECTORY "$ENV{MKLROOT}") set(LAPACK_VENDOR MKL) endif() diff --git a/cmake/scalapack.cmake b/cmake/scalapack.cmake index 6bdfd05..20237ec 100644 --- a/cmake/scalapack.cmake +++ b/cmake/scalapack.cmake @@ -3,11 +3,11 @@ include(GNUInstallDirs) if(find) -if(NOT DEFINED SCALAPACK_VENDOR AND DEFINED ENV{MKLROOT}) +if(NOT DEFINED SCALAPACK_VENDOR AND LAPACK_VENDOR MATCHES "^MKL") set(SCALAPACK_VENDOR MKL) endif() -if(MKL IN_LIST SCALAPACK_VENDOR) +if(MKL IN_LIST SCALAPACK_VENDOR AND NOT MKL64 IN_LIST SCALAPACK_VENDOR) if(intsize64) list(APPEND SCALAPACK_VENDOR MKL64) endif()