generic.cmake 1.4 KB

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