-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindSVML.cmake
60 lines (54 loc) · 2.14 KB
/
FindSVML.cmake
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
# Find the Intel SVML (Vectorization Support)
#
# Usage:
# find_package(SVML)
if(APPLE)
set(SVML_LIB libsvml.dylib)
elseif(WIN32)
set(SVML_LIB svml_dispmd.dll)
else()
set(SVML_LIB libsvml.so)
endif()
find_path(SVML_ROOT_DIR
${SVML_LIB}
PATHS
$ENV{SVMLROOT}
$ENV{CONDA_PREFIX}/lib # conda environments are accessible here (including base)
$ENV{CONDA}/lib # search for conda libs in Azure pipelines
$ENV{CONDA}/Library/bin # same, but for Win (DLL here)
/opt/intel/compilers_and_libraries/linux/lib/intel64_lin # Intel ICC on Linux
/opt/intel/compilers_and_libraries/mac/lib/intel64_lin # Intel ICC on MacOS
)
foreach (LIB ${SVML_LIB})
message(STATUS "Looking ${LIB} in: ${${LIB}_PATH}")
find_file(${LIB}_PATH ${LIB} PATHS ${SVML_ROOT_DIR})
if(${LIB}_PATH)
if(WIN32)
set(SVM_LIBRARY_DLL ${${LIB}_PATH})
message(STATUS "Debug: ${SVM_LIBRARY_DLL}")
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/scripts/dlltolib.bat "${SVM_LIBRARY_DLL}" ${CMAKE_SOURCE_DIR}/scripts/dlltolib.py ${CMAKE_BINARY_DIR})
get_filename_component(SVML_LIBRARY_NAME ${SVM_LIBRARY_DLL} NAME)
string(REPLACE ".dll" ".lib" SVML_LIBRARY_NEWNAME ${SVML_LIBRARY_NAME})
set(SVML_LIBRARY ${CMAKE_BINARY_DIR}/${SVML_LIBRARY_NEWNAME})
file(COPY "${SVM_LIBRARY_DLL}" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
else(WIN32)
set(SVML_LIBRARY ${SVML_LIBRARY} ${${LIB}_PATH})
endif(WIN32)
message(STATUS "Found SVML ${LIB} in: ${SVML_LIBRARY}")
else()
message(FATAL_ERROR "Could not find ${LIB}")
endif()
endforeach()
if (NOT WIN32)
# This is necessary at least on Linux and MacOS
string(REPLACE "svml" "intlc" INTLC_LIBRARY ${SVML_LIBRARY})
string(REPLACE ".so" ".so.5" INTLC_LIBRARY ${INTLC_LIBRARY})
endif()
set(INAC_DEPENDENCY_LIBS ${INAC_DEPENDENCY_LIBS} ${SVML_LIBRARY} ${INTLC_LIBRARY})
if(WIN32)
set(INAC_DEPENDENCY_BINS ${SVM_LIBRARY_DLL})
else()
set(INAC_DEPENDENCY_BINS ${SVML_LIBRARY} ${INTLC_LIBRARY})
file(COPY "${SVML_LIBRARY}" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY "${INTLC_LIBRARY}" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()