Add support for Intel icx/ifx compilers on windows
If I define a toolchain like:
file(TO_CMAKE_PATH "${PROG_ROOT}/Intel/OneAPI/compiler/latest/windows" POSSIBLE_INTEL_COMPILER_ROOT)
find_program(ICX_EXECUTBALE NAMES "icx" "icx.exe" PATHS "${POSSIBLE_INTEL_COMPILER_ROOT}/bin")
find_program(IFX_EXECUTBALE NAMES "ifx" "ifx.exe" PATHS "${POSSIBLE_INTEL_COMPILER_ROOT}/bin")
get_filename_component(INTEL_BIN_DIR "${ICX_EXECUTBALE}" DIRECTORY)
list(INSERT CMAKE_PROGRAM_PATH 0 "${INTEL_BIN_DIR}")
set(CMAKE_C_COMPILER "${ICX_EXECUTBALE}" CACHE STRING "" FORCE)
set(CMAKE_CXX_COMPILER "${ICX_EXECUTBALE}" CACHE STRING "" FORCE)
set(CMAKE_ASM_COMPILER "${ICX_EXECUTBALE}" CACHE STRING "" FORCE)
set(CMAKE_Fortran_COMPILER "${IFX_EXECUTBALE}" CACHE STRING "" FORCE)
set(CMAKE_AR "${INTEL_BIN_DIR}/llvm-ar.exe" CACHE STRING "" FORCE)
set(CMAKE_LINKER "${INTEL_BIN_DIR}/lld-link.exe" CACHE STRING "" FORCE)
set(CMAKE_RANLIB "${INTEL_BIN_DIR}/llvm-ranlib.exe" CACHE STRING "" FORCE)
# Intel compiler does not install 'llvm-ranlib' which is simply 'llvm-ar s' but this cannot be set here.
# so simply copy llvm-ar and rename it! CMake does not give an easy way to inject a flag here.
it works for normal c/c++ projects but for projects like lapack it fails with the following error:
-- The Fortran compiler identification is Intel 2019.0.0.20201113
-- The C compiler identification is Clang 12.0.0 with MSVC-like command-line
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe - skipped
-- Checking whether C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe supports Fortran 90
-- Checking whether C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/ifx.exe supports Fortran 90 - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/icx.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for Python greater than 2.6 -
-- Found PythonInterp: C:/Program Files (x86)/Intel/oneAPI/intelpython/latest/python.exe (found suitable version "3.7.9", minimum required is "2.7")
-- Using Python version 3.7.9
-- Build tests: OFF
CMake Error at G:/vcpkg_common/downloads/tools/cmake-3.18.4-windows/cmake-3.18.4-win32-x86/share/cmake-3.18/Modules/Platform/Windows-MSVC.cmake:71 (message):
MSVC compiler version not detected properly:
Call Stack (most recent call first):
G:/vcpkg_common/downloads/tools/cmake-3.18.4-windows/cmake-3.18.4-win32-x86/share/cmake-3.18/Modules/Platform/Windows-Intel.cmake:11 (include)
G:/vcpkg_common/downloads/tools/cmake-3.18.4-windows/cmake-3.18.4-win32-x86/share/cmake-3.18/Modules/Platform/Windows-Intel-Fortran.cmake:1 (include)
G:/vcpkg_common/downloads/tools/cmake-3.18.4-windows/cmake-3.18.4-win32-x86/share/cmake-3.18/Modules/CMakeFortranInformation.cmake:25 (include)
G:/vcpkg_test/master/buildtrees/lapack-reference/src/v3.8.0-954f10683f.clean/INSTALL/CMakeLists.txt:2 (project)
reducing the fatal error to a warning (and maybe adding set(MSVC_TOOLSET_VERSION 142); I just added it because I knew I had that installed) makes the build succeed but no import library is created. Removing the string replacements in Windows-Intel.cmake concerning xilink generates the "expected" empty import library.