1# SPDX-License-Identifier: Apache-2.0
2
3if(DEFINED ENV{ONEAPI_ROOT})
4  set_ifndef(ONEAPI_TOOLCHAIN_PATH $ENV{ONEAPI_ROOT})
5else()
6  zephyr_get(ONEAPI_TOOLCHAIN_PATH)
7endif()
8
9# the default oneApi installation path is related to os
10string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} system)
11if(ONEAPI_TOOLCHAIN_PATH)
12  set(TOOLCHAIN_HOME ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/${system}/bin/)
13  set(ONEAPI_LLVM_BIN_PATH ${ONEAPI_TOOLCHAIN_PATH}/compiler/latest/${system}/bin-llvm)
14endif()
15
16set(ONEAPI_TOOLCHAIN_PATH ${ONEAPI_TOOLCHAIN_PATH} CACHE PATH "oneApi install directory")
17
18set(LINKER lld)
19set(BINTOOLS oneApi)
20
21if(CONFIG_64BIT)
22  set(triple x86_64-pc-none-elf)
23else()
24  set(triple i686-pc-none-elf)
25endif()
26
27if(system STREQUAL "linux")
28  set(COMPILER icx)
29  set(CMAKE_C_COMPILER_TARGET   ${triple})
30  set(CMAKE_ASM_COMPILER_TARGET ${triple})
31  set(CMAKE_CXX_COMPILER_TARGET ${triple})
32
33# icx compiler of oneApi will invoke clang-cl on windows,
34# this is not supported in zephyr now, so change to use
35# clang directly.
36# and the clang from oneApi can't recognize those cross
37# compiling target variables of cmake, so used other
38# cmake functions to pass them to clang.
39elseif(system STREQUAL "windows")
40  set(COMPILER clang)
41  list(APPEND CMAKE_REQUIRED_FLAGS --target=${triple})
42  add_compile_options(--target=${triple})
43  add_link_options(--target=${triple})
44endif()
45
46set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
47
48message(STATUS "Found toolchain: host (clang/ld)")
49