mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-17 11:45:55 +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>
53 lines
1.9 KiB
CMake
53 lines
1.9 KiB
CMake
# Configuration for host installed llvm
|
|
#
|
|
|
|
set(NOSTDINC "")
|
|
|
|
# Note that NOSYSDEF_CFLAG may be an empty string, and
|
|
# set_ifndef() does not work with empty string.
|
|
if(NOT DEFINED NOSYSDEF_CFLAG)
|
|
set(NOSYSDEF_CFLAG -undef)
|
|
endif()
|
|
|
|
find_program(CMAKE_C_COMPILER clang PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_CXX_COMPILER clang++ PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_AR llvm-ar PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_LINKER llvm-link PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_NM llvm-nm PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_OBJDUMP llvm-objdump PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_RANLIB llvm-ranlib PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
|
|
find_program(CMAKE_OBJCOPY objcopy PATH ${TOOLCHAIN_HOME})
|
|
find_program(CMAKE_READELF readelf PATH ${TOOLCHAIN_HOME})
|
|
|
|
foreach(file_name include include-fixed)
|
|
execute_process(
|
|
COMMAND ${CMAKE_C_COMPILER} --print-file-name=${file_name}
|
|
OUTPUT_VARIABLE _OUTPUT
|
|
)
|
|
string(REGEX REPLACE "\n" "" _OUTPUT ${_OUTPUT})
|
|
|
|
list(APPEND NOSTDINC ${_OUTPUT})
|
|
endforeach()
|
|
|
|
foreach(isystem_include_dir ${NOSTDINC})
|
|
list(APPEND isystem_include_flags -isystem ${isystem_include_dir})
|
|
endforeach()
|
|
|
|
execute_process(
|
|
COMMAND ${CMAKE_C_COMPILER} ${TOOLCHAIN_C_FLAGS} --print-libgcc-file-name
|
|
OUTPUT_VARIABLE LIBGCC_FILE_NAME
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
assert_exists(LIBGCC_FILE_NAME)
|
|
|
|
get_filename_component(LIBGCC_DIR ${LIBGCC_FILE_NAME} DIRECTORY)
|
|
|
|
assert_exists(LIBGCC_DIR)
|
|
|
|
list(APPEND LIB_INCLUDE_DIR "-L\"${LIBGCC_DIR}\"")
|
|
list(APPEND TOOLCHAIN_LIBS gcc)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -nostartfiles -nostdlib ${isystem_include_flags} -Wl,--unresolved-symbols=ignore-in-object-files)
|
|
string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|