# - Find Intel MKL
FIND_PATH(MKL_INCLUDE_DIR mkl.h
    PATHS ENV INCLUDE
    PATHS ${SYSTEM_INC_PATH})

FIND_LIBRARY(MKL_LIBRARY mkl_core
    PATHS ENV LD_LIBRARY_PATH
    PATHS ${SYSTEM_LIB_PATH}
    PATHS ENV LIBRARY_PATH)

GET_FILENAME_COMPONENT(MKL_LIBRARY_DIR ${MKL_LIBRARY} PATH)

IF (MKL_INCLUDE_DIR AND MKL_LIBRARY AND MKL_LIBRARY_DIR)
    if (NOT MKL_LIBRARY_DIR)
        MESSAGE(FATAL_ERROR "Could not find MKL library directory")
    endif(NOT MKL_LIBRARY_DIR)

    IF (NOT MKL_FIND_QUIETLY)
        MESSAGE(STATUS "Found MKL: ${MKL_LIBRARY_DIR}")
    ENDIF (NOT MKL_FIND_QUIETLY)
ELSE (MKL_INCLUDE_DIR AND MKL_LIBRARY)
    IF (MKL_FIND_REQUIRED)
        MESSAGE(FATAL_ERROR "Could not find MKL: $ENV{INCLUDE} $ENV{LD_LIBRARY_PATH}")
    ELSE (MKL_FIND_REQUIRED)
        IF ( NOT MKL_LIBRARY )
            MESSAGE(STATUS "WARNING: Could not find MKL library: $ENV{LD_LIBRARY_PATH}")
        ELSE ( NOT MKL_LIBRARY )
            MESSAGE(STATUS "WARNING: Could not find MKL include: $ENV{INCLUDE}")
        ENDIF ( NOT MKL_LIBRARY )
    ENDIF (MKL_FIND_REQUIRED)
ENDIF (MKL_INCLUDE_DIR AND MKL_LIBRARY AND MKL_LIBRARY_DIR)
