Browse Source

Find{BLAS,LAPACK}: Include parent of points directory in search

This is required if MKLROOT points to the subdirectory .../mkl/ instead of
the root of an Intel MKL library installation. Only in this case the MKL
will be searched starting from the parent directory, to detect relevant
dependencies in parallel subdirectories, like 'compiler' and 'tbb'.
Mario Emmenlauer 5 years ago
parent
commit
807a129f3c
2 changed files with 13 additions and 0 deletions
  1. 7 0
      Modules/FindBLAS.cmake
  2. 6 0
      Modules/FindLAPACK.cmake

+ 7 - 0
Modules/FindBLAS.cmake

@@ -449,6 +449,12 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
       endif()
       endif()
       if(DEFINED ENV{MKLROOT})
       if(DEFINED ENV{MKLROOT})
         set(BLAS_mkl_MKLROOT "$ENV{MKLROOT}")
         set(BLAS_mkl_MKLROOT "$ENV{MKLROOT}")
+        # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead
+        # so we can better detect other relevant libraries in 'compiler' or 'tbb':
+        get_filename_component(BLAS_mkl_MKLROOT_LAST_DIR "${BLAS_mkl_MKLROOT}" NAME)
+        if(BLAS_mkl_MKLROOT_LAST_DIR STREQUAL "mkl")
+            get_filename_component(BLAS_mkl_MKLROOT "${BLAS_mkl_MKLROOT}" DIRECTORY)
+        endif()
       endif()
       endif()
       set(BLAS_mkl_LIB_PATH_SUFFIXES
       set(BLAS_mkl_LIB_PATH_SUFFIXES
           "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}"
           "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}"
@@ -479,6 +485,7 @@ if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
       unset(BLAS_mkl_LM)
       unset(BLAS_mkl_LM)
       unset(BLAS_mkl_LDL)
       unset(BLAS_mkl_LDL)
       unset(BLAS_mkl_MKLROOT)
       unset(BLAS_mkl_MKLROOT)
+      unset(BLAS_mkl_MKLROOT_LAST_DIR)
       unset(BLAS_mkl_ARCH_NAME)
       unset(BLAS_mkl_ARCH_NAME)
       unset(BLAS_mkl_OS_NAME)
       unset(BLAS_mkl_OS_NAME)
       unset(BLAS_mkl_LIB_PATH_SUFFIXES)
       unset(BLAS_mkl_LIB_PATH_SUFFIXES)

+ 6 - 0
Modules/FindLAPACK.cmake

@@ -268,6 +268,12 @@ if(BLAS_FOUND)
         endif()
         endif()
         if(DEFINED ENV{MKLROOT})
         if(DEFINED ENV{MKLROOT})
           set(LAPACK_mkl_MKLROOT "$ENV{MKLROOT}")
           set(LAPACK_mkl_MKLROOT "$ENV{MKLROOT}")
+          # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead
+          # so we can better detect other relevant libraries in 'compiler' or 'tbb':
+          get_filename_component(LAPACK_mkl_MKLROOT_LAST_DIR "${LAPACK_mkl_MKLROOT}" NAME)
+          if(LAPACK_mkl_MKLROOT_LAST_DIR STREQUAL "mkl")
+              get_filename_component(LAPACK_mkl_MKLROOT "${LAPACK_mkl_MKLROOT}" DIRECTORY)
+          endif()
         endif()
         endif()
         set(LAPACK_mkl_LIB_PATH_SUFFIXES
         set(LAPACK_mkl_LIB_PATH_SUFFIXES
             "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"
             "compiler/lib" "compiler/lib/${LAPACK_mkl_ARCH_NAME}_${LAPACK_mkl_OS_NAME}"