title: Compile Eigen + Intel MKL with CMake
body: <p>I want to use the Intel MKL libraries (including the Pardiso solver) with Eigen3. When I manually specify the compiler options in CMake I get it to work (for that I've followed the <a href="https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/" rel="nofollow noreferrer">Intel Link Line Advisor</a>). But I know there is a pre-difined way through <code>FindBLAS.cmake</code> together with the <code>BLA_VENDOR</code> environment variable, in particular using the <a href="https://bitbucket.org/eigen/eigen/src/d589d86fec2021b50fda7eb8a67134fcb664e246/cmake/FindBLAS.cmake?at=default&amp;fileviewer=file-view-default" rel="nofollow noreferrer"><code>FindBLAS.cmake</code></a> modified by Eigen. Only I'm stuck with this. How should I write my <code>CMakeLists.txt</code>? </p>
  
  <p>I should emphesize that use the latests Eigen3 version on a cluster, so have 'installed' it in a non-trivial location in my home-folder. Also after simply using</p>
  
  <pre><code>cmake /path/to/eigen3 -DCMAKE_INSTALL_PREFIX:PATH=$HOME/opt
  make install
  </code></pre>
  
  <p>I did not get the third-party CMake files.</p>
  
  <hr>
  
  <h1>Edit</h1>
  
  <p>I have found a solution that seems to work properly:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.12)
  
  project(main)
  
  set(PROJECT_LIBS "")
  
  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
  
  # find Eigen3, use an environment variable that specifies the root of the Eigen download:
  #   export EIGENPATH="/path/to/clone/of/eigen3/"
  list(APPEND CMAKE_MODULE_PATH "$ENV{EIGENPATH}/cmake/")
  find_package(Eigen3 3.3.0)
  include_directories(${EIGEN3_INCLUDE_DIRS})
  
  # enable Intel-MKL (only for Intel compilers)
  # NB requires correct specification of BLA_VENDOR, e.g.
  #   export BLA_VENDOR=Intel10_64lp_seq
  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
    find_package(BLAS)
    include_directories(${BLAS_INCLUDE_DIRS})
    set(PROJECT_LIBS ${BLAS_LIBRARIES})
    add_definitions(-DEIGEN_USE_MKL_ALL)
  endif()
  
  add_executable(${PROJECT_NAME} main.cpp)
  
  target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS})
  </code></pre>
  
  <blockquote>
    <p>Note that it is important to remark that the 'installation' of Eigen does not work for this solution, as piggy-bagging on pkg-config is not sufficient here. I.e. one should just download/clone Eigen and point CMake to the download location.</p>
  </blockquote>