2023-05-12 03:39:22 +08:00
# This package installs Intel MKL on Linux, macOS and Windows for x64.
# Configuration:
# - ilp64
# - dynamic CRT: intel_thread, static CRT: sequential
2023-03-20 16:27:15 +08:00
set ( VCPKG_POLICY_EMPTY_PACKAGE enabled )
# https://registrationcenter-download.intel.com/akdlm/IRC_NAS/19150/w_onemkl_p_2023.0.0.25930_offline.exe # windows
# https://registrationcenter-download.intel.com/akdlm/IRC_NAS/19116/m_onemkl_p_2023.0.0.25376_offline.dmg # macos
# https://registrationcenter-download.intel.com/akdlm/irc_nas/19138/l_onemkl_p_2023.0.0.25398_offline.sh # linux
set ( sha "" )
2023-05-12 03:39:22 +08:00
if ( NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
# nop
elseif ( VCPKG_TARGET_IS_WINDOWS )
2023-03-20 16:27:15 +08:00
set ( filename w_onemkl_p_2023.0.0.25930_offline.exe )
set ( magic_number 19150 )
set ( sha a3eb6b75241a2eccb73ed73035ff111172c55d3fa51f545c7542277a155df84ff72fc826621711153e683f84058e64cb549c030968f9f964531db76ca8a3ed46 )
2023-05-12 03:39:22 +08:00
set ( package_infix "win" )
elseif ( VCPKG_TARGET_IS_OSX )
2023-03-20 16:27:15 +08:00
set ( filename m_onemkl_p_2023.0.0.25376_offline.dmg )
set ( magic_number 19116 )
set ( sha 7b9b8c004054603e6830fb9b9c049d5a4cfc0990c224cb182ac5262ab9f1863775a67491413040e3349c590e2cca58edcfc704db9f3b9f9faa8b5b09022cd2af )
2023-05-12 03:39:22 +08:00
set ( package_infix "mac" )
set ( package_libdir "lib" )
set ( compiler_libdir "mac/compiler/lib" )
2023-03-20 16:27:15 +08:00
elseif ( VCPKG_TARGET_IS_LINUX )
set ( filename l_onemkl_p_2023.0.0.25398_offline.sh )
set ( magic_number 19138 )
set ( sha b5f2f464675f0fd969dde2faf2e622b834eb1cc406c4a867148116f6c24ba5c709d98b678840f4a89a1778e12cde0ff70ce2ef59faeef3d3f3aa1d0329c71af1 )
2023-05-12 03:39:22 +08:00
set ( package_infix "lin" )
set ( package_libdir "lib/intel64" )
set ( compiler_libdir "linux/compiler/lib/intel64_lin" )
endif ( )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
if ( NOT sha )
message ( WARNING "${PORT} is empty for ${TARGET_TRIPLET}." )
return ( )
endif ( )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
vcpkg_download_distfile ( installer_path
U R L S " h t t p s : / / r e g i s t r a t i o n c e n t e r - d o w n l o a d . i n t e l . c o m / a k d l m / I R C _ N A S / $ { m a g i c _ n u m b e r } / $ { f i l e n a m e } "
F I L E N A M E " $ { f i l e n a m e } "
S H A 5 1 2 " $ { s h a } "
)
# Note: intel_thread and lp64 are the defaults.
set ( interface "ilp64" ) # or ilp64; ilp == 64 bit int api
#https://www.intel.com/content/www/us/en/develop/documentation/onemkl-linux-developer-guide/top/linking-your-application-with-onemkl/linking-in-detail/linking-with-interface-libraries/using-the-ilp64-interface-vs-lp64-interface.html
if ( VCPKG_CRT_LINKAGE STREQUAL "dynamic" )
set ( threading "intel_thread" ) #sequential or intel_thread or tbb_thread or pgi_thread
else ( )
set ( threading "sequential" )
endif ( )
if ( threading STREQUAL "intel_thread" )
set ( short_thread "iomp" )
else ( )
string ( SUBSTRING "${threading}" "0" "3" short_thread )
2023-03-20 16:27:15 +08:00
endif ( )
2023-05-12 03:39:22 +08:00
set ( main_pc_file "mkl-${VCPKG_LIBRARY_LINKAGE}-${interface}-${short_thread}.pc" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
# First extraction level: packages (from offline installer)
set ( extract_0_dir "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-extract" )
file ( REMOVE_RECURSE "${extract_0_dir}" )
file ( MAKE_DIRECTORY "${extract_0_dir}" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
# Second extraction level: actual files (from packages)
set ( extract_1_dir "${CURRENT_PACKAGES_DIR}/intel-extract" )
file ( REMOVE_RECURSE "${extract_1_dir}" )
file ( MAKE_DIRECTORY "${extract_1_dir}" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/pkgconfig" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
if ( VCPKG_TARGET_IS_WINDOWS )
2023-03-20 16:27:15 +08:00
vcpkg_find_acquire_program ( 7Z )
2023-05-12 03:39:22 +08:00
message ( STATUS "Extracting offline installer" )
vcpkg_execute_required_process (
C O M M A N D " $ { 7 Z } " x " $ { i n s t a l l e r _ p a t h } " " - o $ { e x t r a c t _ 0 _ d i r } " " - y " " - b s o 0 " " - b s p 0 "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 0 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - 0 "
)
2023-03-20 16:27:15 +08:00
set ( packages
" i n t e l . o n e a p i . w i n . m k l . d e v e l , v = 2 0 2 3 . 0 . 0 - 2 5 9 3 0 / o n e a p i - m k l - d e v e l - f o r - i n s t a l l e r _ p _ 2 0 2 3 . 0 . 0 . 2 5 9 3 0 . m s i " # has the required libs.
" i n t e l . o n e a p i . w i n . m k l . r u n t i m e , v = 2 0 2 3 . 0 . 0 - 2 5 9 3 0 / o n e a p i - m k l - f o r - i n s t a l l e r _ p _ 2 0 2 3 . 0 . 0 . 2 5 9 3 0 . m s i " # has the required DLLs
#"intel.oneapi.win.compilers-common-runtime,v=2023.0.0-25922" # SVML
" i n t e l . o n e a p i . w i n . o p e n m p , v = 2 0 2 3 . 0 . 0 - 2 5 9 2 2 / o n e a p i - c o m p - o p e n m p - f o r - i n s t a l l e r _ p _ 2 0 2 3 . 0 . 0 . 2 5 9 2 2 . m s i " # OpenMP
#"intel.oneapi.win.tbb.runtime,v=2021.8.0-25874" #TBB
)
foreach ( pack IN LISTS packages )
2023-05-12 03:39:22 +08:00
set ( package_path "${extract_0_dir}/packages/${pack}" )
2023-03-20 16:27:15 +08:00
cmake_path ( GET pack STEM LAST_ONLY packstem )
2023-05-12 03:39:22 +08:00
cmake_path ( NATIVE_PATH package_path package_path_native )
vcpkg_execute_required_process (
C O M M A N D " $ { L E S S M S I } " x " $ { p a c k a g e _ p a t h _ n a t i v e } "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 1 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - $ { p a c k s t e m } "
)
file ( COPY "${extract_1_dir}/${packstem}/SourceDir/" DESTINATION "${extract_1_dir}" )
file ( REMOVE_RECURSE "${extract_1_dir}/${packstem}" )
2023-03-20 16:27:15 +08:00
endforeach ( )
2023-05-12 03:39:22 +08:00
set ( mkl_dir "${extract_1_dir}/Intel/Compiler/12.0/mkl/2023.0.0" )
file ( COPY "${mkl_dir}/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" )
2023-03-20 16:27:15 +08:00
# see https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html for linking
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
set ( files "mkl_core_dll.lib" "mkl_${threading}_dll.lib" "mkl_intel_${interface}_dll.lib" "mkl_blas95_${interface}.lib" "mkl_lapack95_${interface}.lib" ) # "mkl_rt.lib" single dynamic lib with dynamic dispatch
2023-05-12 03:39:22 +08:00
file ( COPY "${mkl_dir}/redist/intel64/" DESTINATION "${CURRENT_PACKAGES_DIR}/bin" ) # Could probably be reduced instead of copying all
2023-03-20 16:27:15 +08:00
if ( NOT VCPKG_BUILD_TYPE )
2023-05-12 03:39:22 +08:00
file ( COPY "${mkl_dir}/redist/intel64/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin" )
2023-03-20 16:27:15 +08:00
endif ( )
else ( )
set ( files "mkl_core.lib" "mkl_${threading}.lib" "mkl_intel_${interface}.lib" "mkl_blas95_${interface}.lib" "mkl_lapack95_${interface}.lib" )
endif ( )
2023-05-12 03:39:22 +08:00
foreach ( file IN LISTS files )
file ( COPY "${mkl_dir}/lib/intel64/${file}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/intel64" ) # instead of manual-link keep normal structure
2023-03-20 16:27:15 +08:00
if ( NOT VCPKG_BUILD_TYPE )
2023-05-12 03:39:22 +08:00
file ( COPY "${mkl_dir}/lib/intel64/${file}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/intel64" )
2023-03-20 16:27:15 +08:00
endif ( )
endforeach ( )
2023-05-12 03:39:22 +08:00
file ( COPY_FILE "${mkl_dir}/lib/pkgconfig/${main_pc_file}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
set ( compiler_dir "${extract_1_dir}/Intel/Compiler/12.0/compiler/2023.0.0" )
2023-03-20 16:27:15 +08:00
if ( threading STREQUAL "intel_thread" )
2023-05-12 03:39:22 +08:00
file ( COPY "${compiler_dir}/windows/redist/intel64_win/compiler/" DESTINATION "${CURRENT_PACKAGES_DIR}/bin" )
file ( COPY "${compiler_dir}/windows/compiler/lib/intel64_win/" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/intel64" )
file ( COPY_FILE "${compiler_dir}/lib/pkgconfig/openmp.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" )
2023-03-20 16:27:15 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" "/windows/compiler/lib/intel64_win/" "/lib/intel64/" )
2023-06-27 11:27:30 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" "-I \${includedir}" "-I\" \${includedir}\"")
2023-05-12 03:39:22 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "openmp" "libiomp5" )
2023-03-20 16:27:15 +08:00
if ( NOT VCPKG_BUILD_TYPE )
2023-05-12 03:39:22 +08:00
file ( COPY "${compiler_dir}/windows/redist/intel64_win/compiler/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin" )
file ( COPY "${compiler_dir}/windows/compiler/lib/intel64_win/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/intel64" )
2023-03-20 16:27:15 +08:00
endif ( )
endif ( )
2023-05-12 03:39:22 +08:00
else ( )
message ( STATUS " Warning: This port is still a work on progress.
E . g . i t i s n o t c o r r e c t l y f i l t e r i n g t h e l i b r a r i e s i n a c c o r d a n c e w i t h
V C P K G _ L I B R A R Y _ L I N K A G E . I t i s u s i n g t h e d e f a u l t threading ( Intel OpenMP )
w h i c h i s k n o w n t o s e g f a u l t w h e n u s e d t o g e t h e r w i t h G N U O p e n M P .
" )
message ( STATUS "Extracting offline installer" )
if ( VCPKG_TARGET_IS_LINUX )
vcpkg_execute_required_process (
C O M M A N D " b a s h " " - - v e r b o s e " " - - n o p r o f i l e " " $ { i n s t a l l e r _ p a t h } " " - - e x t r a c t - o n l y " " - - e x t r a c t - f o l d e r " " $ { e x t r a c t _ 0 _ d i r } "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 0 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - 0 "
2023-03-20 16:27:15 +08:00
)
2023-05-12 03:39:22 +08:00
file ( RENAME "${extract_0_dir}/l_onemkl_p_2023.0.0.25398_offline/packages" "${extract_0_dir}/packages" )
elseif ( VCPKG_TARGET_IS_OSX )
find_program ( HDIUTIL NAMES hdiutil REQUIRED )
file ( MAKE_DIRECTORY "${extract_0_dir}/packages" )
message ( STATUS "... Don't interrupt." )
vcpkg_execute_required_process (
C O M M A N D " $ { C M A K E _ C O M M A N D } " " - D d m g _ p a t h = $ { i n s t a l l e r _ p a t h } "
" - D o u t p u t _ d i r = $ { e x t r a c t _ 0 _ d i r } / p a c k a g e s "
" - D H D I U T I L = $ { H D I U T I L } "
- P " $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / c o p y - f r o m - d m g . c m a k e "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 0 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - 0 "
)
message ( STATUS "... Done." )
endif ( )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( GLOB package_path "${extract_0_dir}/packages/intel.oneapi.${package_infix}.mkl.runtime,v=2023.0.0-*" )
cmake_path ( GET package_path STEM LAST_ONLY packstem )
message ( STATUS "Extracting ${packstem}" )
vcpkg_execute_required_process (
C O M M A N D " $ { C M A K E _ C O M M A N D } " " - E " " t a r " " - x f " " $ { p a c k a g e _ p a t h } / c u p P a y l o a d . c u p "
" _ i n s t a l l d i r / m k l / 2 0 2 3 . 0 . 0 / l i b "
" _ i n s t a l l d i r / m k l / 2 0 2 3 . 0 . 0 / l i c e n s i n g "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 1 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - $ { p a c k s t e m } "
)
file ( GLOB package_path "${extract_0_dir}/packages/intel.oneapi.${package_infix}.mkl.devel,v=2023.0.0-*" )
cmake_path ( GET package_path STEM LAST_ONLY packstem )
message ( STATUS "Extracting ${packstem}" )
vcpkg_execute_required_process (
C O M M A N D " $ { C M A K E _ C O M M A N D } " " - E " " t a r " " - x f " " $ { p a c k a g e _ p a t h } / c u p P a y l o a d . c u p "
" _ i n s t a l l d i r / m k l / 2 0 2 3 . 0 . 0 / b i n "
" _ i n s t a l l d i r / m k l / 2 0 2 3 . 0 . 0 / i n c l u d e "
" _ i n s t a l l d i r / m k l / 2 0 2 3 . 0 . 0 / l i b "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 1 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - $ { p a c k s t e m } "
)
file ( GLOB package_path "${extract_0_dir}/packages/intel.oneapi.${package_infix}.openmp,v=2023.0.0-*" )
cmake_path ( GET package_path STEM LAST_ONLY packstem )
message ( STATUS "Extracting ${packstem}" )
vcpkg_execute_required_process (
C O M M A N D " $ { C M A K E _ C O M M A N D } " " - E " " t a r " " - x f " " $ { p a c k a g e _ p a t h } / c u p P a y l o a d . c u p "
" _ i n s t a l l d i r / c o m p i l e r / 2 0 2 3 . 0 . 0 "
W O R K I N G _ D I R E C T O R Y " $ { e x t r a c t _ 1 _ d i r } "
L O G N A M E " e x t r a c t - $ { T A R G E T _ T R I P L E T } - $ { p a c k s t e m } "
)
set ( mkl_dir "${extract_1_dir}/_installdir/mkl/2023.0.0" )
file ( COPY "${mkl_dir}/include/" DESTINATION "${CURRENT_PACKAGES_DIR}/include" )
file ( COPY "${mkl_dir}/${package_libdir}/" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/intel64" )
2023-03-20 16:27:15 +08:00
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" )
set ( to_remove_suffix .a )
2023-05-12 03:39:22 +08:00
elseif ( VCPKG_TARGET_IS_OSX )
set ( to_remove_suffix .dylib )
2023-03-20 16:27:15 +08:00
else ( )
set ( to_remove_suffix .so )
endif ( )
2023-05-12 03:39:22 +08:00
file ( GLOB_RECURSE files_to_remove
" $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b / i n t e l 6 4 / * $ { t o _ r e m o v e _ s u f f i x } "
" $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b / i n t e l 6 4 / * $ { t o _ r e m o v e _ s u f f i x } . ? "
)
2023-03-20 16:27:15 +08:00
file ( REMOVE ${ files_to_remove } )
2023-05-12 03:39:22 +08:00
file ( COPY_FILE "${mkl_dir}/lib/pkgconfig/${main_pc_file}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" )
2024-06-20 05:07:05 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "\${exec_prefix}/${package_libdir}" "\${exec_prefix}/lib/intel64" IGNORE_UNCHANGED )
2023-05-12 03:39:22 +08:00
set ( compiler_dir "${extract_1_dir}/_installdir/compiler/2023.0.0" )
if ( threading STREQUAL "intel_thread" )
file ( COPY "${compiler_dir}/${compiler_libdir}/" DESTINATION "${CURRENT_PACKAGES_DIR}/lib/intel64" )
file ( COPY_FILE "${compiler_dir}/lib/pkgconfig/openmp.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" )
2024-06-20 05:07:05 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" "/${compiler_libdir}/" "/lib/intel64/" IGNORE_UNCHANGED )
2023-05-12 03:39:22 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "openmp" "libiomp5" )
2023-03-20 16:27:15 +08:00
endif ( )
2023-05-12 03:39:22 +08:00
endif ( )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( COPY_FILE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/mkl.pc" )
if ( NOT VCPKG_BUILD_TYPE )
file ( MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig" )
file ( GLOB pc_files RELATIVE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/*.pc" )
foreach ( file IN LISTS pc_files )
file ( COPY_FILE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${file}" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${file}" )
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${file}" "/include" "/../include" )
if ( NOT VCPKG_TARGET_IS_WINDOWS )
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${file}" "/lib/intel64" "/../lib/intel64" )
2023-03-20 16:27:15 +08:00
endif ( )
2023-05-12 03:39:22 +08:00
endforeach ( )
endif ( )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( COPY "${mkl_dir}/lib/cmake/" DESTINATION "${CURRENT_PACKAGES_DIR}/share/" )
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" "MKL_CMAKE_PATH}/../../../" "MKL_CMAKE_PATH}/../../" )
2023-09-01 04:34:33 +08:00
vcpkg_replace_string ( "${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" "redist/\${MKL_ARCH}" "bin" )
2023-05-12 03:39:22 +08:00
#TODO: Hardcode settings from portfile in config.cmake
#TODO: Give lapack/blas information about the correct BLA_VENDOR depending on settings.
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( INSTALL "${mkl_dir}/licensing" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" )
file ( GLOB package_path "${extract_0_dir}/packages/intel.oneapi.${package_infix}.mkl.product,v=2023.0.0-*" )
vcpkg_install_copyright ( FILE_LIST "${package_path}/licenses/license.htm" )
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( REMOVE_RECURSE
" $ { e x t r a c t _ 0 _ d i r } "
" $ { e x t r a c t _ 1 _ d i r } "
" $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b / i n t e l 6 4 / c m a k e "
" $ { C U R R E N T _ P A C K A G E S _ D I R } / l i b / i n t e l 6 4 / p k g c o n f i g "
)
2023-03-20 16:27:15 +08:00
2023-05-12 03:39:22 +08:00
file ( INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" )