2019-04-06 15:08:09 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-12-16 10:05:20 +01:00
|
|
|
# Prevent CMake from testing the toolchain
|
|
|
|
set(CMAKE_C_COMPILER_FORCED 1)
|
|
|
|
set(CMAKE_CXX_COMPILER_FORCED 1)
|
|
|
|
|
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()
|
cmake: ensure consistent behavior between x_ROOT settings
Fixes: #23825
Today, BOARD, SOC, ARCH, DTS, KCONFIG, and TOOLCHAIN_ROOT can be
specified by users or through other CMake files.
It is not clear if relative paths are permitted and/or from where a
relative path is constructed.
Inside CMake, it is very easy to specify `${ZEPHYR_BASE}`,
`${CMAKE_CURRENT_SOURCE_DIR}`, or similar, thus there is no reason to
use relative path inside CMake, as it easy can lead to discussion on
relative to what.
For users manually invoking CMake using, `cmake ... <app-dir>` it is
nice to have to possibility to specify a relative path.
For this purpose, relative path are considered relative to the
`APPLICATION_SOURCE_DIR`.
This commit updates:
- BOARD_ROOT
- SOC_ROOT
- ARCH_ROOT
- DTS_ROOT
- KCONFIG_ROOT
- TOOLCHAIN_ROOT
to allow paths relative to `APPLICATION_SOURCE_DIR` when specified with
`-D<type>_ROOT=<relative-path>`
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-08 14:07:00 +02:00
|
|
|
zephyr_file(APPLICATION_ROOT TOOLCHAIN_ROOT)
|
2018-09-25 13:05:58 +02:00
|
|
|
|
2018-09-03 10:54:16 +02:00
|
|
|
# Don't inherit compiler flags from the environment
|
2020-09-05 11:38:03 +02:00
|
|
|
foreach(var AFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS)
|
2018-09-03 10:54:16 +02:00
|
|
|
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()
|
|
|
|
|
2019-03-08 13:52:11 +01:00
|
|
|
# Host-tools don't unconditionally set TOOLCHAIN_HOME anymore,
|
|
|
|
# but in case Zephyr's SDK toolchain is used, set TOOLCHAIN_HOME
|
|
|
|
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr")
|
|
|
|
set(TOOLCHAIN_HOME ${HOST_TOOLS_HOME})
|
|
|
|
endif()
|
2018-09-25 13:05:58 +02:00
|
|
|
|
cmake: ensure consistent behavior between x_ROOT settings
Fixes: #23825
Today, BOARD, SOC, ARCH, DTS, KCONFIG, and TOOLCHAIN_ROOT can be
specified by users or through other CMake files.
It is not clear if relative paths are permitted and/or from where a
relative path is constructed.
Inside CMake, it is very easy to specify `${ZEPHYR_BASE}`,
`${CMAKE_CURRENT_SOURCE_DIR}`, or similar, thus there is no reason to
use relative path inside CMake, as it easy can lead to discussion on
relative to what.
For users manually invoking CMake using, `cmake ... <app-dir>` it is
nice to have to possibility to specify a relative path.
For this purpose, relative path are considered relative to the
`APPLICATION_SOURCE_DIR`.
This commit updates:
- BOARD_ROOT
- SOC_ROOT
- ARCH_ROOT
- DTS_ROOT
- KCONFIG_ROOT
- TOOLCHAIN_ROOT
to allow paths relative to `APPLICATION_SOURCE_DIR` when specified with
`-D<type>_ROOT=<relative-path>`
Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-09-08 14:07:00 +02:00
|
|
|
set(TOOLCHAIN_ROOT ${TOOLCHAIN_ROOT} CACHE STRING "Zephyr toolchain root" FORCE)
|
2018-09-25 13:05:58 +02:00
|
|
|
assert(TOOLCHAIN_ROOT "Zephyr toolchain root path invalid: please set the TOOLCHAIN_ROOT-variable")
|
|
|
|
|
2020-04-06 23:15:39 +02:00
|
|
|
# Set cached ZEPHYR_TOOLCHAIN_VARIANT.
|
2018-02-11 21:36:21 +01:00
|
|
|
set(ZEPHYR_TOOLCHAIN_VARIANT ${ZEPHYR_TOOLCHAIN_VARIANT} CACHE STRING "Zephyr toolchain variant")
|
2018-01-08 17:06:42 +01:00
|
|
|
|
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
|
|
|
|
2020-01-24 16:39:40 +01:00
|
|
|
set_ifndef(TOOLCHAIN_KCONFIG_DIR ${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT})
|
|
|
|
|
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.)
|
2019-07-03 10:09:09 +02:00
|
|
|
include(${TOOLCHAIN_ROOT}/cmake/compiler/${COMPILER}/generic.cmake OPTIONAL)
|
|
|
|
include(${TOOLCHAIN_ROOT}/cmake/linker/${LINKER}/generic.cmake OPTIONAL)
|
cmake: Toolchain abstraction: Abstraction of binary tools, foundation.
This forms the foundation for the abstraction of the binary tools,
where the following steps are taken:
- Move binary tool resolving, such as objcopy, objdump, readelf and
so forth, out of compiler definitions and place in a dedicated binary
tools folder with the binary tools supplier as subfolder, similar to
the compiler and linker directories.
- Create binary tool sets, gnu, host-gnu and llvm.
- Each toolchain selects the required set of binary tools by setting
BINTOOLS via its generic.cmake as it also does for compiler and linker.
The intent here is to abstract Zephyr's dependence on toolchains,
thus allowing for easier porting to other, perhaps commercial,
toolchains and/or usecases.
No functional change expected.
Signed-off-by: Danny Oerndrup <daor@demant.com>
2019-07-18 15:06:51 +02:00
|
|
|
include(${TOOLCHAIN_ROOT}/cmake/bintools/${BINTOOLS}/generic.cmake OPTIONAL)
|