Commit 18d314e7 authored by Peng Chen's avatar Peng Chen Committed by Anas Nashif
Browse files

cmake: oneApi: add oneApi support on windows



The icx compiler of oneApi will invoke clang-cl on windows,
this is not supported in zephyr now, so change to use
clang directly.
And the clang from oneApi can't recognize those cross
compiling target variables of cmake, such as
CMAKE_C_COMPILER_TARGET, so used other cmake functions
to pass them to clang.

Signed-off-by: default avatarChen Peng1 <peng1.chen@intel.com>
parent c8755e0b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ if(NOT "${ARCH}" STREQUAL "posix")
    list(APPEND TOOLCHAIN_LIBS gcc)
  endif()

  set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
  list(APPEND CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
  string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")

endif()
+21 −5
Original line number Diff line number Diff line
@@ -6,14 +6,15 @@ else()
  set_ifndef(ONEAPI_TOOLCHAIN_PATH "$ENV{ONEAPI_TOOLCHAIN_PATH}")
endif()

# the default oneApi installation path is related to os
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} system)
if(ONEAPI_TOOLCHAIN_PATH)
  set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/linux/bin/)
  set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/${system}/bin/)
  set(ONEAPI_PYTHON_PATH ${ONEAPI_TOOLCHAIN_PATH}/intelpython/latest/bin)
endif()

set(ONEAPI_TOOLCHAIN_PATH ${ONEAPI_TOOLCHAIN_PATH} CACHE PATH "oneApi install directory")

set(COMPILER icx)
set(LINKER lld)
set(BINTOOLS oneApi)

@@ -23,8 +24,23 @@ else()
  set(triple i686-pc-none-elf)
endif()

if(system STREQUAL "linux")
  set(COMPILER icx)
  set(CMAKE_C_COMPILER_TARGET   ${triple})
  set(CMAKE_ASM_COMPILER_TARGET ${triple})
  set(CMAKE_CXX_COMPILER_TARGET ${triple})

# icx compiler of oneApi will invoke clang-cl on windows,
# this is not supported in zephyr now, so change to use
# clang directly.
# and the clang from oneApi can't recognize those cross
# compiling target variables of cmake, so used other
# cmake functions to pass them to clang.
elseif(system STREQUAL "windows")
  set(COMPILER clang)
  list(APPEND CMAKE_REQUIRED_FLAGS --target=${triple})
  add_compile_options(--target=${triple})
  add_link_options(--target=${triple})
endif()

message(STATUS "Found toolchain: host (clang/ld)")