1# SPDX-License-Identifier: Apache-2.0
2
3# Configuration for host installed oneApi
4#
5
6set(NOSTDINC "")
7
8# Note that NOSYSDEF_CFLAG may be an empty string, and
9# set_ifndef() does not work with empty string.
10if(NOT DEFINED NOSYSDEF_CFLAG)
11  set(NOSYSDEF_CFLAG -undef)
12endif()
13
14if(DEFINED TOOLCHAIN_HOME)
15  set(find_program_icx_args PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
16endif()
17
18find_program(CMAKE_C_COMPILER   icx   ${find_program_icx_args})
19find_program(CMAKE_CXX_COMPILER clang++ ${find_program_icx_args})
20
21include(${ZEPHYR_BASE}/cmake/gcc-m-cpu.cmake)
22
23foreach(file_name include/stddef.h)
24  execute_process(
25    COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
26    OUTPUT_VARIABLE _OUTPUT
27    RESULT_VARIABLE result
28    )
29  if(result)
30    message(FATAL_ERROR "Failed to find required headers.")
31  endif()
32  get_filename_component(_OUTPUT "${_OUTPUT}" DIRECTORY)
33  string(REGEX REPLACE "\n" "" _OUTPUT "${_OUTPUT}")
34
35  list(APPEND NOSTDINC ${_OUTPUT})
36endforeach()
37
38foreach(isystem_include_dir ${NOSTDINC})
39  list(APPEND isystem_include_flags -isystem "\"${isystem_include_dir}\"")
40endforeach()
41
42if(CONFIG_64BIT)
43  list(APPEND TOOLCHAIN_C_FLAGS "-m64")
44else()
45  list(APPEND TOOLCHAIN_C_FLAGS "-m32")
46endif()
47
48
49# This libgcc code is partially duplicated in compiler/*/target.cmake
50execute_process(
51  COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
52  OUTPUT_VARIABLE LIBGCC_FILE_NAME
53  OUTPUT_STRIP_TRAILING_WHITESPACE
54  )
55
56get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
57
58list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
59if(LIBGCC_DIR)
60  list(APPEND TOOLCHAIN_LIBS gcc)
61endif()
62
63set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags})
64string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
65
66# Load toolchain_cc-family macros
67macro(toolchain_cc_nostdinc)
68    zephyr_compile_options( -nostdinc)
69endmacro()
70
71if(CONFIG_CPP)
72  list(APPEND TOOLCHAIN_C_FLAGS "-no-intel-lib=libirc")
73endif()
74