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 Intel Link Line Advisor). But I know there is a pre-difined way through FindBLAS.cmake
together with the BLA_VENDOR
environment variable, in particular using the FindBLAS.cmake
modified by Eigen. Only I'm stuck with this. How should I write my CMakeLists.txt
?
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
cmake /path/to/eigen3 -DCMAKE_INSTALL_PREFIX:PATH=$HOME/opt
make install
I did not get the third-party CMake files.
Edit
I have found a solution that seems to work properly:
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})
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.