2018-09-25 19:05:58 +08:00
|
|
|
if(NOT TOOLCHAIN_ROOT)
|
|
|
|
if(DEFINED ENV{TOOLCHAIN_ROOT})
|
|
|
|
# Support for out-of-tree toolchain
|
|
|
|
set(TOOLCHAIN_ROOT $ENV{TOOLCHAIN_ROOT})
|
|
|
|
else()
|
|
|
|
# Default toolchain cmake file
|
|
|
|
set(TOOLCHAIN_ROOT ${ZEPHYR_BASE})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-09-03 16:54:16 +08:00
|
|
|
# Don't inherit compiler flags from the environment
|
|
|
|
foreach(var CFLAGS CXXFLAGS)
|
|
|
|
if(DEFINED ENV{${var}})
|
|
|
|
message(WARNING "The environment variable '${var}' was set to $ENV{${var}},
|
|
|
|
but Zephyr ignores flags from the environment. Use 'cmake -DEXTRA_${var}=$ENV{${var}}' instead.")
|
|
|
|
unset(ENV{${var}})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2018-02-12 04:36:21 +08:00
|
|
|
# Until we completely deprecate it
|
2018-05-31 01:52:27 +08:00
|
|
|
if(NOT DEFINED ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
|
|
|
if(DEFINED ENV{ZEPHYR_GCC_VARIANT})
|
|
|
|
message(WARNING "ZEPHYR_GCC_VARIANT is deprecated, please use ZEPHYR_TOOLCHAIN_VARIANT instead")
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT $ENV{ZEPHYR_GCC_VARIANT})
|
|
|
|
endif()
|
2018-02-12 04:36:21 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ZEPHYR_TOOLCHAIN_VARIANT)
|
|
|
|
if(DEFINED ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT $ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
2018-11-19 21:50:42 +08:00
|
|
|
elseif(CROSS_COMPILE OR (DEFINED ENV{CROSS_COMPILE}))
|
2018-02-12 04:36:21 +08:00
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT cross-compile)
|
2018-01-09 00:06:42 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2018-08-03 23:11:23 +08:00
|
|
|
|
|
|
|
# Until we completely deprecate it
|
2018-09-24 19:50:25 +08:00
|
|
|
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "gccarmemb")
|
2018-08-03 23:11:23 +08:00
|
|
|
message(WARNING "gccarmemb is deprecated, please use gnuarmemb instead")
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT "gnuarmemb")
|
|
|
|
endif()
|
|
|
|
|
2018-09-25 19:05:58 +08:00
|
|
|
|
|
|
|
set(TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root")
|
|
|
|
assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable")
|
|
|
|
|
2018-02-12 04:36:21 +08:00
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant")
|
|
|
|
assert(ZEPHYR_TOOLCHAIN_VARIANT "Zephyr toolchain variant invalid: please set the ZEPHYR_TOOLCHAIN_VARIANT-variable")
|
2018-01-09 00:06:42 +08:00
|
|
|
|
2019-01-10 00:24:35 +08:00
|
|
|
# Pick host system's toolchain if we are targeting posix
|
|
|
|
if(${ARCH} STREQUAL "posix")
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT "host")
|
2018-01-09 00:06:42 +08:00
|
|
|
endif()
|
|
|
|
|
2017-10-27 21:43:34 +08:00
|
|
|
# Configure the toolchain based on what SDK/toolchain is in use.
|
2019-01-10 00:24:35 +08:00
|
|
|
include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake)
|
2017-10-27 21:43:34 +08:00
|
|
|
|
|
|
|
# Configure the toolchain based on what toolchain technology is used
|
2018-01-09 00:05:26 +08:00
|
|
|
# (gcc, host-gcc etc.)
|
2018-12-13 23:32:07 +08:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL)
|