Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# a simple cmake script to locate Intel Math Kernel Library
# This script looks for two places:
# - the environment variable MKLROOT
# - the directory /opt/intel/mkl
# Stage 1: find the root directory
set(MKLROOT_PATH $ENV{MKLROOT})
if (NOT MKLROOT_PATH)
# try to find at /opt/intel/mkl
if (EXISTS "/opt/intel/mkl")
set(MKLROOT_PATH "/opt/intel/mkl")
endif (EXISTS "/opt/intel/mkl")
endif (NOT MKLROOT_PATH)
# Stage 2: find include path and libraries
if (MKLROOT_PATH)
# root-path found
set(EXPECT_MKL_INCPATH "${MKLROOT_PATH}/include")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib")
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(EXPECT_ICC_LIBPATH "$ENV{ICC_LIBPATH}")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
if (CMAKE_SIZEOF_VOID_P MATCHES 8)
set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib/intel64")
else (CMAKE_SIZEOF_VOID_P MATCHES 8)
set(EXPECT_MKL_LIBPATH "${MKLROOT_PATH}/lib/ia32")
endif (CMAKE_SIZEOF_VOID_P MATCHES 8)
endif (CMAKE_SYSTEM_NAME MATCHES "Linux")
# set include
if (IS_DIRECTORY ${EXPECT_MKL_INCPATH})
set(MKL_INCLUDE_DIR ${EXPECT_MKL_INCPATH})
endif (IS_DIRECTORY ${EXPECT_MKL_INCPATH})
if (IS_DIRECTORY ${EXPECT_MKL_LIBPATH})
set(MKL_LIBRARY_DIR ${EXPECT_MKL_LIBPATH})
endif (IS_DIRECTORY ${EXPECT_MKL_LIBPATH})
# find specific library files
find_library(LIB_MKL_RT NAMES mkl_rt HINTS ${MKL_LIBRARY_DIR})
find_library(LIB_PTHREAD NAMES pthread)
endif (MKLROOT_PATH)
set(MKL_LIBRARY
${LIB_MKL_RT}
${LIB_PTHREAD})
# deal with QUIET and REQUIRED argument
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG
MKL_LIBRARY_DIR
LIB_MKL_RT
LIB_PTHREAD
MKL_INCLUDE_DIR)
mark_as_advanced(LIB_MKL_RT LIB_PTHREAD MKL_INCLUDE_DIR)