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>
33 lines
955 B
CMake
33 lines
955 B
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
find_appropriate_cache_directory(USER_CACHE_DIR)
|
|
|
|
if((NOT "${USER_CACHE_DIR}" STREQUAL "") AND (EXISTS "${USER_CACHE_DIR}"))
|
|
message(STATUS "Invalidating toolchain capability cache in ${USER_CACHE_DIR}")
|
|
execute_process(COMMAND
|
|
${CMAKE_COMMAND} -E remove_directory "${USER_CACHE_DIR}")
|
|
endif()
|
|
|
|
if(DEFINED $ENV{CLANG_ROOT_DIR})
|
|
set(TOOLCHAIN_HOME ${CLANG_ROOT}/bin/)
|
|
endif()
|
|
|
|
set(COMPILER clang)
|
|
set(LINKER ld) # TODO: Use lld eventually rather than GNU ld
|
|
set(BINTOOLS llvm)
|
|
|
|
if("${ARCH}" STREQUAL "arm")
|
|
set(triple arm-none-eabi)
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
|
|
elseif("${ARCH}" STREQUAL "x86")
|
|
set(triple i686-pc-none-elf)
|
|
endif()
|
|
|
|
set(CMAKE_C_COMPILER_TARGET ${triple})
|
|
set(CMAKE_ASM_COMPILER_TARGET ${triple})
|
|
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
|
|
|
if("${ARCH}" STREQUAL "posix")
|
|
set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
|
|
endif()
|