generic.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # SPDX-License-Identifier: Apache-2.0
  2. set_ifndef(XTOOLS_TOOLCHAIN_PATH "$ENV{XTOOLS_TOOLCHAIN_PATH}")
  3. set( XTOOLS_TOOLCHAIN_PATH ${XTOOLS_TOOLCHAIN_PATH} CACHE PATH "")
  4. assert( XTOOLS_TOOLCHAIN_PATH "XTOOLS_TOOLCHAIN_PATH is not set")
  5. set(TOOLCHAIN_HOME ${XTOOLS_TOOLCHAIN_PATH})
  6. set(COMPILER gcc)
  7. set(LINKER ld)
  8. set(BINTOOLS gnu)
  9. # Choose one of the toolchains in 'TOOLCHAIN_HOME' at random to use as
  10. # a 'generic' toolchain until we know for sure which toolchain we
  11. # should use. Note that we can't use ARCH to distinguish between
  12. # toolchains because choosing between iamcu and non-iamcu is dependent
  13. # on Kconfig, not ARCH.
  14. if("${ARCH}" STREQUAL "xtensa")
  15. file(GLOB toolchain_paths ${TOOLCHAIN_HOME}/xtensa/*/*)
  16. else()
  17. file(GLOB toolchain_paths ${TOOLCHAIN_HOME}/*)
  18. endif()
  19. list(REMOVE_ITEM toolchain_paths ${TOOLCHAIN_HOME}/sources)
  20. list(GET toolchain_paths 0 some_toolchain_path)
  21. get_filename_component(some_toolchain_root "${some_toolchain_path}" DIRECTORY)
  22. get_filename_component(some_toolchain "${some_toolchain_path}" NAME)
  23. set(CROSS_COMPILE_TARGET ${some_toolchain})
  24. set(SYSROOT_TARGET ${CROSS_COMPILE_TARGET})
  25. set(CROSS_COMPILE ${some_toolchain_root}/${CROSS_COMPILE_TARGET}/bin/${CROSS_COMPILE_TARGET}-)
  26. set(SYSROOT_DIR ${some_toolchain_root}/${SYSROOT_TARGET}/${SYSROOT_TARGET})
  27. set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib")
  28. unset(some_toolchain_root)
  29. unset(some_toolchain)
  30. message(STATUS "Found toolchain: xtools (${XTOOLS_TOOLCHAIN_PATH})")