generic_toolchain.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # SPDX-License-Identifier: Apache-2.0
  2. if(NOT TOOLCHAIN_ROOT)
  3. if(DEFINED ENV{TOOLCHAIN_ROOT})
  4. # Support for out-of-tree toolchain
  5. set(TOOLCHAIN_ROOT $ENV{TOOLCHAIN_ROOT})
  6. else()
  7. # Default toolchain cmake file
  8. set(TOOLCHAIN_ROOT ${ZEPHYR_BASE})
  9. endif()
  10. endif()
  11. zephyr_file(APPLICATION_ROOT TOOLCHAIN_ROOT)
  12. # Don't inherit compiler flags from the environment
  13. foreach(var AFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS)
  14. if(DEFINED ENV{${var}})
  15. message(WARNING "The environment variable '${var}' was set to $ENV{${var}},
  16. but Zephyr ignores flags from the environment. Use 'cmake -DEXTRA_${var}=$ENV{${var}}' instead.")
  17. unset(ENV{${var}})
  18. endif()
  19. endforeach()
  20. # Host-tools don't unconditionally set TOOLCHAIN_HOME anymore,
  21. # but in case Zephyr's SDK toolchain is used, set TOOLCHAIN_HOME
  22. if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr")
  23. set(TOOLCHAIN_HOME ${HOST_TOOLS_HOME})
  24. endif()
  25. set(TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root" FORCE)
  26. assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable")
  27. # Set cached ZEPHYR_TOOLCHAIN_VARIANT.
  28. set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant")
  29. # Configure the toolchain based on what SDK/toolchain is in use.
  30. include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake)
  31. set_ifndef(TOOLCHAIN_KCONFIG_DIR ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT})
  32. # Configure the toolchain based on what toolchain technology is used
  33. # (gcc, host-gcc etc.)
  34. include(${TOOLCHAIN_ROOT}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL)
  35. include(${TOOLCHAIN_ROOT}/cmake/linker/${LINKER}/generic.cmake OPTIONAL)
  36. include(${TOOLCHAIN_ROOT}/cmake/bintools/${BINTOOLS}/generic.cmake OPTIONAL)