toolchain: cmake: Off-tree toolchains gets other.h included if selected

To ensure that an off-tree toolchain gets the toolchain/other.h header
included, such that it can include the correct header for the
toolchain via the other.h, the define __TOOLCHAIN_CUSTOM__ will be set
when ever the cmake flag TOOLCHAIN_USE_CUSTOM is set.
An off-tree toolchain needs to set the set(TOOLCHAIN_USE_CUSTOM 1) in
the off-tree generic.cmake and/or target.cmake, in order for the
include/other.h to be included. The generic.cmake and target.cmake will
be under ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/

As the TOOLCHAIN_USE_CUSTOM is only set for off-tree toolchains, this
has no impact on in-tree toolchains and their functionality.

Fixes zephyrproject-rtos#36117

Signed-off-by: Danny Oerndrup <daor@demant.com>
This commit is contained in:
Danny Oerndrup 2021-07-16 11:50:40 +02:00 committed by Anas Nashif
commit 94202f3ed7
2 changed files with 12 additions and 5 deletions

View file

@ -95,6 +95,11 @@ zephyr_compile_definitions(
__ZEPHYR__=1
)
# Ensure that include/toolchain.h includes toolchain/other.h for all off-tree toolchains
if(TOOLCHAIN_USE_CUSTOM)
zephyr_compile_definitions(__TOOLCHAIN_CUSTOM__)
endif()
# @Intent: Set compiler flags to enable buffer overflow checks in libc functions
# @config in CONFIG_NO_OPTIMIZATIONS optional : Optimizations may affect security
zephyr_compile_definitions($<TARGET_PROPERTY:compiler,security_fortify> )