2019-04-06 15:08:09 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-09-25 13:05:58 +02: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 10:54:16 +02: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-11 21:36:21 +01:00
|
|
|
# Until we completely deprecate it
|
2018-05-30 19:52:27 +02: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-11 21:36:21 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ZEPHYR_TOOLCHAIN_VARIANT)
|
|
|
|
if(DEFINED ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT $ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
2018-11-19 14:50:42 +01:00
|
|
|
elseif(CROSS_COMPILE OR (DEFINED ENV{CROSS_COMPILE}))
|
2018-02-11 21:36:21 +01:00
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT cross-compile)
|
2018-01-08 17:06:42 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
2018-08-03 17:11:23 +02:00
|
|
|
|
|
|
|
# Until we completely deprecate it
|
2018-09-24 13:50:25 +02:00
|
|
|
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "gccarmemb")
|
2018-08-03 17:11:23 +02:00
|
|
|
message(WARNING "gccarmemb is deprecated, please use gnuarmemb instead")
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT "gnuarmemb")
|
|
|
|
endif()
|
|
|
|
|
2018-09-25 13:05:58 +02: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-11 21:36:21 +01: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-08 17:06:42 +01:00
|
|
|
|
2019-01-09 17:24:35 +01:00
|
|
|
# Pick host system's toolchain if we are targeting posix
|
2019-02-10 15:22:26 +01:00
|
|
|
if((${ARCH} STREQUAL "posix") OR (${ARCH} STREQUAL "x86_64"))
|
2019-03-08 11:37:57 +01:00
|
|
|
if(NOT "${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "llvm")
|
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT "host")
|
|
|
|
endif()
|
2018-01-08 17:06:42 +01:00
|
|
|
endif()
|
|
|
|
|
2017-10-27 15:43:34 +02:00
|
|
|
# Configure the toolchain based on what SDK/toolchain is in use.
|
2019-01-09 17:24:35 +01:00
|
|
|
include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake)
|
2017-10-27 15:43:34 +02:00
|
|
|
|
|
|
|
# Configure the toolchain based on what toolchain technology is used
|
2018-01-08 17:05:26 +01:00
|
|
|
# (gcc, host-gcc etc.)
|
2018-12-13 16:32:07 +01:00
|
|
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL)
|