1# SPDX-License-Identifier: Apache-2.0 2 3# No official documentation exists for the "Generic" value, except their wiki. 4# 5# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling: 6# CMAKE_SYSTEM_NAME : this one is mandatory, it is the name of the target 7# system, i.e. the same as CMAKE_SYSTEM_NAME would have if CMake would run 8# on the target system. Typical examples are "Linux" and "Windows". This 9# variable is used for constructing the file names of the platform files 10# like Linux.cmake or Windows-gcc.cmake. If your target is an embedded 11# system without OS set CMAKE_SYSTEM_NAME to "Generic". 12set(CMAKE_SYSTEM_NAME Generic) 13 14# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_PROCESSOR.html: 15# The name of the CPU CMake is building for. 16# 17# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling: 18# CMAKE_SYSTEM_PROCESSOR : optional, processor (or hardware) of the 19# target system. This variable is not used very much except for one 20# purpose, it is used to load a 21# CMAKE_SYSTEM_NAME-compiler-CMAKE_SYSTEM_PROCESSOR.cmake file, 22# which can be used to modify settings like compiler flags etc. for 23# the target 24set(CMAKE_SYSTEM_PROCESSOR ${ARCH}) 25 26# https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_VERSION.html: 27# When the CMAKE_SYSTEM_NAME variable is set explicitly to enable cross 28# compiling then the value of CMAKE_SYSTEM_VERSION must also be set 29# explicitly to specify the target system version. 30set(CMAKE_SYSTEM_VERSION ${PROJECT_VERSION}) 31 32# We are not building dynamically loadable libraries 33set(BUILD_SHARED_LIBS OFF) 34 35# Custom targets for compiler and linker flags. 36add_custom_target(asm) 37add_custom_target(compiler) 38add_custom_target(compiler-cpp) 39add_custom_target(linker) 40 41if(NOT (COMPILER STREQUAL "host-gcc")) 42 include(${TOOLCHAIN_ROOT}/cmake/toolchain/${ZEPHYR_TOOLCHAIN_VARIANT}/target.cmake) 43endif() 44 45# The 'generic' compiler and the 'target' compiler might be different, 46# so we unset the 'generic' one and thereby force the 'target' to 47# re-set it. 48unset(CMAKE_C_COMPILER) 49unset(CMAKE_C_COMPILER CACHE) 50 51# A toolchain consist of a compiler and a linker. 52# In Zephyr, toolchains require a port under cmake/toolchain/. 53# Each toolchain port must set COMPILER and LINKER. 54# E.g. toolchain/llvm may pick {clang, ld} or {clang, lld}. 55add_custom_target(bintools) 56 57include(${TOOLCHAIN_ROOT}/cmake/compiler/${COMPILER}/target.cmake OPTIONAL) 58include(${TOOLCHAIN_ROOT}/cmake/linker/${LINKER}/target.cmake OPTIONAL) 59include(${CMAKE_CURRENT_LIST_DIR}/bintools/bintools_template.cmake) 60include(${TOOLCHAIN_ROOT}/cmake/bintools/${BINTOOLS}/target.cmake OPTIONAL) 61