From 81afba630670b9ea4621dbaa4748dfdd395246dd Mon Sep 17 00:00:00 2001 From: Duncan Palmer Date: Mon, 28 Nov 2016 16:07:14 +1000 Subject: [PATCH] Ensure MKL detection doesn't depend on MKL header files being present. Apparently, MKL installations don't always include header files. So detect MKL libraries and headers seperately. --- dlib/CMakeLists.txt | 2 +- dlib/cmake_utils/cmake_find_blas.txt | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dlib/CMakeLists.txt b/dlib/CMakeLists.txt index 594c8abfc..43f0e98ee 100644 --- a/dlib/CMakeLists.txt +++ b/dlib/CMakeLists.txt @@ -474,7 +474,7 @@ if (NOT TARGET dlib) endif() if (DLIB_USE_MKL_FFT) - if (found_intel_mkl) + if (found_intel_mkl AND found_intel_mkl_headers) set (dlib_needed_libraries ${dlib_needed_libraries} ${mkl_libraries}) include_directories(${mkl_include_dir}) else() diff --git a/dlib/cmake_utils/cmake_find_blas.txt b/dlib/cmake_utils/cmake_find_blas.txt index 0db436ff7..7b1f848b8 100644 --- a/dlib/cmake_utils/cmake_find_blas.txt +++ b/dlib/cmake_utils/cmake_find_blas.txt @@ -8,13 +8,14 @@ # attempts to find some other BLAS and LAPACK libraries if you don't have # the Intel MKL. # -# blas_found - True if BLAS is available -# lapack_found - True if LAPACK is available -# found_intel_mkl - True is the the Intel MKL library is available -# blas_libraries - link against these to use BLAS library -# lapack_libraries - link against these to use LAPACK library -# mkl_libraries - link against these to use the MKL library -# mkl_include_dir - add to the include path to use the MKL library +# blas_found - True if BLAS is available +# lapack_found - True if LAPACK is available +# found_intel_mkl - True if the Intel MKL library is available +# found_intel_mkl_headers - True if Intel MKL headers are available +# blas_libraries - link against these to use BLAS library +# lapack_libraries - link against these to use LAPACK library +# mkl_libraries - link against these to use the MKL library +# mkl_include_dir - add to the include path to use the MKL library # setting this makes CMake allow normal looking if else statements SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) @@ -22,6 +23,7 @@ SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) SET(blas_found 0) SET(lapack_found 0) SET(found_intel_mkl 0) +SET(found_intel_mkl_headers 0) if (UNIX) @@ -95,7 +97,7 @@ if (UNIX) find_library(mkl_rt mkl_rt ${mkl_search_path}) mark_as_advanced( mkl_rt ) # if we found the MKL - if (mkl_include_dir AND mkl_rt) + if ( mkl_rt) set(mkl_libraries ${mkl_rt} ) set(blas_libraries ${mkl_rt} ) set(lapack_libraries ${mkl_rt} ) @@ -115,7 +117,7 @@ if (UNIX) mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp mkl_pthread) # If we found the MKL - if (mkl_include_dir AND mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread) + if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread) set(mkl_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread}) @@ -126,6 +128,10 @@ if (UNIX) endif() endif() + if (found_intel_mkl AND mkl_include_dir) + set(found_intel_mkl_headers 1) + endif() + # try to find some other LAPACK libraries if we didn't find the MKL set(extra_paths /usr/lib64