Skip to content

Commit 6a60413

Browse files
committed
CMake: move gcc arm related function to GCC_ARM.cmake
1 parent a1b29d0 commit 6a60413

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

CMakeLists.txt

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,40 +71,12 @@ function(mbed_configure_app_target target)
7171
mbed_set_language_standard(${target})
7272
endfunction()
7373

74-
# GCC ARM requires preprecessing linker script, execute generators to get definitions needed for
75-
# this step - linker options and compile definitions
76-
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
77-
78-
# Get definitions - we need them for linker preprocessing
79-
set(_compile_definitions
80-
"$<TARGET_PROPERTY:mbed-os,COMPILE_DEFINITIONS>"
81-
)
82-
83-
set(_linker_options
84-
"$<TARGET_PROPERTY:mbed-os,LINK_OPTIONS>"
85-
)
86-
87-
set(_compile_definitions
88-
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
89-
)
90-
91-
function(generate_definitions)
92-
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
93-
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/linker_options.txt" CONTENT "${_linker_options}\n")
94-
endfunction()
95-
96-
generate_definitions()
97-
set(_linker_preprocess_definitions @${CMAKE_BINARY_DIR}/compile_time_defs.txt)
98-
set(_linker_preprocess_options @${CMAKE_BINARY_DIR}/linker_options.txt)
99-
100-
endif()
101-
10274
#
10375
# Specifies linker script used for linking `target`.
10476
#
10577
function(mbed_set_mbed_target_linker_script target)
10678
get_property(mbed_target_linker_script GLOBAL PROPERTY MBED_TARGET_LINKER_FILE)
107-
79+
mbed_generate_gcc_options_for_linker(mbed-os _linker_preprocess_definitions _linker_preprocess_options)
10880
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
10981
set(CMAKE_PRE_BUILD_COMMAND
11082
COMMAND "arm-none-eabi-cpp" -E -P

cmake/toolchains/GCC_ARM.cmake

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,23 @@ function(mbed_set_toolchain_options target)
5555
${link_options}
5656
)
5757
endfunction()
58+
59+
# GCC ARM requires preprecessing linker script, execute generators to get definitions needed for
60+
# this step - linker options and compile definitions
61+
function(mbed_generate_gcc_options_for_linker target definitions_file linker_options_file)
62+
set(_compile_definitions
63+
"$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>"
64+
)
65+
66+
set(_linker_options
67+
"$<TARGET_PROPERTY:${target},LINK_OPTIONS>"
68+
)
69+
70+
set(_compile_definitions
71+
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
72+
)
73+
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
74+
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/linker_options.txt" CONTENT "${_linker_options}\n")
75+
set(definitions_file @${CMAKE_BINARY_DIR}/compile_time_defs.txt)
76+
set(linker_options_file @${CMAKE_BINARY_DIR}/linker_options.txt)
77+
endfunction()

0 commit comments

Comments
 (0)