mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-02 20:42:30 +00:00
Split up the toolchain configuration into two phases, generic and target. The 'generic' phase configures the toolchain just enough to be able to preprocess DT files. The 'target' phase completes the configuration with target-specific configuration. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
62 lines
2.2 KiB
CMake
62 lines
2.2 KiB
CMake
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()
|
|
|
|
# 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()
|
|
|
|
# Until we completely deprecate it
|
|
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()
|
|
endif()
|
|
|
|
if(NOT ZEPHYR_TOOLCHAIN_VARIANT)
|
|
if(DEFINED ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT $ENV{ZEPHYR_TOOLCHAIN_VARIANT})
|
|
elseif(CROSS_COMPILE OR (DEFINED ENV{CROSS_COMPILE}))
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT cross-compile)
|
|
endif()
|
|
endif()
|
|
|
|
# Until we completely deprecate it
|
|
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "gccarmemb")
|
|
message(WARNING "gccarmemb is deprecated, please use gnuarmemb instead")
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT "gnuarmemb")
|
|
endif()
|
|
|
|
|
|
set(TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root")
|
|
assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable")
|
|
|
|
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")
|
|
|
|
if(${ARCH} STREQUAL "posix" OR (ZEPHYR_TOOLCHAIN_VARIANT STREQUAL "host"))
|
|
set(COMPILER host-gcc)
|
|
endif()
|
|
|
|
|
|
# Configure the toolchain based on what SDK/toolchain is in use.
|
|
if(NOT (COMPILER STREQUAL "host-gcc"))
|
|
include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/generic.cmake)
|
|
endif()
|
|
|
|
# Configure the toolchain based on what toolchain technology is used
|
|
# (gcc, host-gcc etc.)
|
|
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL)
|