mirror of https://github.com/ARMmbed/mbed-os.git
CMake: make linker option generator function toolchain-agnostic
parent
f2278567d0
commit
80a0a5b440
|
@ -133,7 +133,7 @@ endfunction()
|
|||
function(mbed_set_mbed_target_linker_script target)
|
||||
get_property(mbed_target_linker_script GLOBAL PROPERTY MBED_TARGET_LINKER_FILE)
|
||||
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||
mbed_generate_gcc_options_for_linker(${target} _linker_preprocess_definitions)
|
||||
mbed_generate_options_for_linker(${target} _linker_preprocess_definitions)
|
||||
set(CMAKE_PRE_BUILD_COMMAND
|
||||
COMMAND "arm-none-eabi-cpp" ${_linker_preprocess_definitions} -x assembler-with-cpp -E -Wp,-P
|
||||
${mbed_target_linker_script} -o ${CMAKE_BINARY_DIR}/${target}.link_script.ld
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
# Copyright (c) 2020 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# Generate a file containing compile definitions
|
||||
function(mbed_generate_options_for_linker target definitions_file)
|
||||
set(_compile_definitions
|
||||
"$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>"
|
||||
)
|
||||
|
||||
# Remove macro definitions that contain spaces as the lack of escape sequences and quotation marks
|
||||
# in the macro when retrieved using generator expressions causes linker errors.
|
||||
# This includes string macros, array macros, and macros with operations.
|
||||
# TODO CMake: Add escape sequences and quotation marks where necessary instead of removing these macros.
|
||||
set(_compile_definitions
|
||||
"$<FILTER:${_compile_definitions},EXCLUDE, +>"
|
||||
)
|
||||
|
||||
# Append -D to all macros as we pass these as response file to cxx compiler
|
||||
set(_compile_definitions
|
||||
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
|
||||
)
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
|
||||
set(${definitions_file} @${CMAKE_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)
|
||||
endfunction()
|
||||
# Set the system processor depending on the CPU core type
|
||||
if (MBED_CPU_CORE STREQUAL Cortex-A9)
|
||||
set(CMAKE_SYSTEM_PROCESSOR cortex-a9)
|
||||
|
|
|
@ -58,28 +58,6 @@ function(mbed_set_toolchain_options target)
|
|||
)
|
||||
endfunction()
|
||||
|
||||
# Generate a file containing compile definitions
|
||||
function(mbed_generate_gcc_options_for_linker target definitions_file)
|
||||
set(_compile_definitions
|
||||
"$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>"
|
||||
)
|
||||
|
||||
# Remove macro definitions that contain spaces as the lack of escape sequences and quotation marks
|
||||
# in the macro when retrieved using generator expressions causes linker errors.
|
||||
# This includes string macros, array macros, and macros with operations.
|
||||
# TODO CMake: Add escape sequences and quotation marks where necessary instead of removing these macros.
|
||||
set(_compile_definitions
|
||||
"$<FILTER:${_compile_definitions},EXCLUDE, +>"
|
||||
)
|
||||
|
||||
# Append -D to all macros as we pass these as response file to cxx compiler
|
||||
set(_compile_definitions
|
||||
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
|
||||
)
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
|
||||
set(${definitions_file} @${CMAKE_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Configure the toolchain to select the selected C library
|
||||
function(mbed_set_c_lib target lib_type)
|
||||
if (${lib_type} STREQUAL "small")
|
||||
|
|
Loading…
Reference in New Issue