|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +# Configuration for host installed oneApi |
| 4 | +# |
| 5 | + |
| 6 | +set(NOSTDINC "") |
| 7 | + |
| 8 | +# Note that NOSYSDEF_CFLAG may be an empty string, and |
| 9 | +# set_ifndef() does not work with empty string. |
| 10 | +if(NOT DEFINED NOSYSDEF_CFLAG) |
| 11 | + set(NOSYSDEF_CFLAG -undef) |
| 12 | +endif() |
| 13 | + |
| 14 | +if(DEFINED TOOLCHAIN_HOME) |
| 15 | + set(find_program_icx_args PATHS ${TOOLCHAIN_HOME} NO_DEFAULT_PATH) |
| 16 | +endif() |
| 17 | + |
| 18 | +find_program(CMAKE_C_COMPILER icx ${find_program_icx_args}) |
| 19 | +find_program(CMAKE_CXX_COMPILER clang++ ${find_program_icx_args}) |
| 20 | + |
| 21 | +include(${ZEPHYR_BASE}/cmake/gcc-m-cpu.cmake) |
| 22 | + |
| 23 | +foreach(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}) |
| 36 | +endforeach() |
| 37 | + |
| 38 | +foreach(isystem_include_dir ${NOSTDINC}) |
| 39 | + list(APPEND isystem_include_flags -isystem ${isystem_include_dir}) |
| 40 | +endforeach() |
| 41 | + |
| 42 | +if(CONFIG_64BIT) |
| 43 | + string(APPEND TOOLCHAIN_C_FLAGS "-m64") |
| 44 | +else() |
| 45 | + string(APPEND TOOLCHAIN_C_FLAGS "-m32") |
| 46 | +endif() |
| 47 | + |
| 48 | + |
| 49 | +# This libgcc code is partially duplicated in compiler/*/target.cmake |
| 50 | +execute_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 | + |
| 56 | +get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY) |
| 57 | + |
| 58 | +list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"") |
| 59 | +if(LIBGCC_DIR) |
| 60 | + list(APPEND TOOLCHAIN_LIBS gcc) |
| 61 | +endif() |
| 62 | + |
| 63 | +set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags}) |
| 64 | +string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") |
| 65 | + |
| 66 | +# Load toolchain_cc-family macros |
| 67 | +macro(toolchain_cc_nostdinc) |
| 68 | + zephyr_compile_options( -nostdinc) |
| 69 | +endmacro() |
0 commit comments