1# SPDX-License-Identifier: Apache-2.0
2
3# CROSS_COMPILE is a KBuild mechanism for specifying an external
4# toolchain with a single environment variable.
5#
6# It is a legacy mechanism that will in Zephyr translate to
7# specifying ZEPHYR_TOOLCHAIN_VARIANT to 'cross-compile' with the location
8# 'CROSS_COMPILE'.
9#
10# New users should set the env var 'ZEPHYR_TOOLCHAIN_VARIANT' to
11# 'cross-compile' and the 'CROSS_COMPILE' env var to the toolchain
12# prefix. This interface is consistent with the other non-"Zephyr SDK"
13# toolchains.
14#
15# It can be set from either the environment or from a CMake variable
16# of the same name.
17#
18# The env var has the lowest precedence.
19
20if((NOT (DEFINED CROSS_COMPILE)) AND (DEFINED ENV{CROSS_COMPILE}))
21  set(CROSS_COMPILE $ENV{CROSS_COMPILE})
22endif()
23
24set(   CROSS_COMPILE ${CROSS_COMPILE} CACHE PATH "")
25assert(CROSS_COMPILE "CROSS_COMPILE is not set")
26
27set(COMPILER gcc)
28set(LINKER ld)
29set(BINTOOLS gnu)
30
31message(STATUS "Found toolchain: cross-compile (${CROSS_COMPILE})")
32