Search code examples
c++cmakeclion

How to set MKL on Linux with Cmake


I've used the same code provided in this link How to setup MKL on linux with CMake

But i'm getting this error Could NOT find MKL (missing: MKL_LIBRARIES MKL_INCLUDE_DIRS

I've tried to set MKLROOT to the following SET(ENV{MKLROOT} "/home/usr/intel/mkl:$ENV{MKLROOT}")

This is how findmkl.cmake module looks like without the line of code to set the environment for mklroot (i've used the same code in the link below)

https://gist.github.com/scivision/5108cf6ab1515f581a84cd9ad1ef72aa

i suspect the issue is setting the mklroot but not sure, any help is appreciated.


Solution

  • If MKLROOT is initially unset, the statement SET(ENV{MKLROOT} "/home/usr/intel/mkl:$ENV{MKLROOT}") sets MKLROOT equal to /home/usr/intel/mkl:, which is an incorrect format for the path. Instead, you could use

    set(ENV{MKLROOT} "/home/usr/intel/mkl")
    

    Alternatively, you can set the value of that environment variable externally, e.g.,

    source /home/usr/intel/bin/compilervars.sh intel64
    

    and then run CMake. In that case, there is no need for the CMake set statement, which is a more portable solution.

    UPDATE: As of 20th Feb 2021 compilervars.sh is not provided within Intel MKL and the environment should be set with the following command:

    source /opt/intel/oneapi/setvars.sh intel64
    

    or wherever oneAPI is installed.