target.cmake 1.9 KB

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