Skip to content

Commit

Permalink
Do nothing for unsupported targets
Browse files Browse the repository at this point in the history
The old code was already broken.
  • Loading branch information
dg0yt committed Apr 30, 2023
1 parent 53cc12b commit e7aaff3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 100 deletions.
153 changes: 61 additions & 92 deletions ports/intel-mkl/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# This package installs Intel MKL on Linux and Windows for x64 and on other platforms tries to search for it.
# The installation for the platforms are:
# - Windows: ilp64, intel_thread (!static_crt), sequential(static_crt)
# - Linux: ilp64, intel_thread
# This package installs Intel MKL on Linux, macOS and Windows for x64.
# Configuration:
# - ilp64
# - dynamic CRT: intel_thread, static CRT: sequential

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

set(MKL_REQUIRED_VERSION "20200000")

# 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 "")
if(VCPKG_TARGET_IS_WINDOWS)
if(NOT VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
# nop
elseif(VCPKG_TARGET_IS_WINDOWS)
set(filename w_onemkl_p_2023.0.0.25930_offline.exe)
set(magic_number 19150)
set(sha a3eb6b75241a2eccb73ed73035ff111172c55d3fa51f545c7542277a155df84ff72fc826621711153e683f84058e64cb549c030968f9f964531db76ca8a3ed46)
Expand All @@ -30,70 +30,47 @@ elseif(VCPKG_TARGET_IS_LINUX)
set(package_infix "lin")
set(package_libdir "lib/intel64")
set(compiler_libdir "linux/compiler/lib/intel64_lin")
else()
set(ProgramFilesx86 "ProgramFiles(x86)")
set(INTEL_ROOT $ENV{${ProgramFilesx86}}/IntelSWTools/compilers_and_libraries/windows)
set(ONEMKL_ROOT $ENV{${ProgramFilesx86}}/Intel/oneAPI/mkl/latest)

find_path(MKL_ROOT include/mkl.h
PATHS
$ENV{MKLROOT}
${INTEL_ROOT}/mkl
$ENV{ONEAPI_ROOT}/mkl/latest
${ONEMKL_ROOT}
DOC
"Folder contains MKL")

if (MKL_ROOT STREQUAL "MKL_ROOT-NOTFOUND")
message(FATAL_ERROR "Could not find MKL. Before continuing, please download and install MKL (${MKL_REQUIRED_VERSION} or higher) from:"
"\n https://registrationcenter.intel.com/en/products/download/3178/\n"
"\nAlso ensure vcpkg has been rebuilt with the latest version (v0.0.104 or later)")
endif()

file(STRINGS "${MKL_ROOT}/include/mkl_version.h" MKL_VERSION_DEFINITION REGEX "INTEL_MKL_VERSION")
string(REGEX MATCH "([0-9]+)" MKL_VERSION ${MKL_VERSION_DEFINITION})

if (MKL_VERSION LESS MKL_REQUIRED_VERSION)
message(FATAL_ERROR "MKL ${MKL_VERSION} is found but ${MKL_REQUIRED_VERSION} is required. Please download and install a more recent version of MKL from:"
"\n https://registrationcenter.intel.com/en/products/download/3178/\n")
endif()
endif()

if(sha)
vcpkg_download_distfile(installer_path
URLS "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/${magic_number}/${filename}"
FILENAME "${filename}"
SHA512 ${sha}
)
if(NOT sha)
message(WARNING "${PORT} is empty for ${TARGET_TRIPLET}.")
return()
endif()

# 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)
endif()
set(main_pc_file "mkl-${VCPKG_LIBRARY_LINKAGE}-${interface}-${short_thread}.pc")
vcpkg_download_distfile(installer_path
URLS "https://registrationcenter-download.intel.com/akdlm/IRC_NAS/${magic_number}/${filename}"
FILENAME "${filename}"
SHA512 "${sha}"
)

# 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)
endif()
set(main_pc_file "mkl-${VCPKG_LIBRARY_LINKAGE}-${interface}-${short_thread}.pc")

# First extraction level: packages (from offline installer)
set(extract_0_dir "${CURRENT_BUILDTREES_DIR}/intel-extract/${TARGET_TRIPLET}")
file(REMOVE_RECURSE "${extract_0_dir}")
file(MAKE_DIRECTORY "${extract_0_dir}")
# First extraction level: packages (from offline installer)
set(extract_0_dir "${CURRENT_BUILDTREES_DIR}/intel-extract/${TARGET_TRIPLET}")
file(REMOVE_RECURSE "${extract_0_dir}")
file(MAKE_DIRECTORY "${extract_0_dir}")

# 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}")
# 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}")

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/pkgconfig")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/pkgconfig")

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_find_acquire_program(7Z)
message(STATUS "Extracting offline installer")
vcpkg_execute_required_process(
Expand Down Expand Up @@ -155,7 +132,7 @@ if(sha)
file(COPY "${compiler_dir}/windows/compiler/lib/intel64_win/" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib/intel64")
endif()
endif()
else()
else()
message(STATUS "Warning: This port is still a work on progress.
E.g. it is not correctly filtering the libraries in accordance with
VCPKG_LIBRARY_LINKAGE. It is using the default threading (Intel OpenMP)
Expand Down Expand Up @@ -243,10 +220,10 @@ if(sha)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libiomp5.pc" "/${compiler_libdir}/" "/lib/intel64/")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "openmp" "libiomp5")
endif()
endif()
endif()

file(COPY_FILE "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${main_pc_file}" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/mkl.pc")
if(NOT VCPKG_BUILD_TYPE)
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)
Expand All @@ -256,31 +233,23 @@ if(sha)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${file}" "/lib/intel64" "/../lib/intel64")
endif()
endforeach()
endif()

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}/../../")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" "redist/\${MKL_ARCH}/" "bin")
#TODO: Hardcode settings from portfile in config.cmake
#TODO: Give lapack/blas information about the correct BLA_VENDOR depending on settings.

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")

file(REMOVE_RECURSE
"${extract_0_dir}"
"${extract_1_dir}"
"${CURRENT_PACKAGES_DIR}/lib/intel64/cmake"
"${CURRENT_PACKAGES_DIR}/lib/intel64/pkgconfig"
)
endif()

if(NOT sha)
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake" @ONLY)
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/mkl/vcpkg-cmake-wrapper.cmake" @ONLY)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" "bin\${MKL_DLL_GLOB" "bin/\${MKL_DLL_GLOB")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" [["../bincompiler" "../compiler/lib"]] [["bin" "../bincompiler" "../compiler/lib"]])
endif()
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}/../../")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/mkl/MKLConfig.cmake" "redist/\${MKL_ARCH}/" "bin")
#TODO: Hardcode settings from portfile in config.cmake
#TODO: Give lapack/blas information about the correct BLA_VENDOR depending on settings.

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")

file(REMOVE_RECURSE
"${extract_0_dir}"
"${extract_1_dir}"
"${CURRENT_PACKAGES_DIR}/lib/intel64/cmake"
"${CURRENT_PACKAGES_DIR}/lib/intel64/pkgconfig"
)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
6 changes: 0 additions & 6 deletions ports/intel-mkl/vcpkg-cmake-wrapper.cmake

This file was deleted.

1 change: 0 additions & 1 deletion ports/intel-mkl/vcpkg-port-config.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion versions/i-/intel-mkl.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"versions": [
{
"git-tree": "9c3e8fe24d87fc7540784a162f3bd096eb6b047f",
"git-tree": "c9b7de74ee1e05ce6a7a834ffcf3984083a1a006",
"version": "2023.0.0",
"port-version": 1
},
Expand Down

0 comments on commit e7aaff3

Please sign in to comment.