Skip to content

Commit 053bcf4

Browse files
committed
Support application profile link selection
This provides one approach to address cmake link mess with mbed-core-flags/ mbed-rtos-flags whose links or not depends on selected application profile, full or bare-metal. 1. Add target config option application-profile for application to select which application profile to use. Applications are responsible for make this target config option consitent with link selection of mbed-os/mbed-baremetal. 2. Add cmake interface library mbed-application-profile-flags. It is to substitute for mbed-core-flags/mbed-rtos-flags. Library camke targets should change to link this one to build upon correct application profile selection.
1 parent fb69ee2 commit 053bcf4

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,38 @@ add_library(mbed-rtos-sources INTERFACE) # Collects source files that are in mbe
121121
add_library(mbed-core-flags INTERFACE) # Collects flags common to mbed-baremetal and mbed-os
122122
add_library(mbed-core-sources INTERFACE) # Collects source files common to mbed-baremetal and mbed-os
123123

124+
# Add mbed-application-profile-flags which is to substitue for mbed-core-flags/
125+
# mbed-rtos-flags whose linking need to depend on selected application profile
126+
add_library(mbed-application-profile-flags INTERFACE)
127+
target_link_libraries(mbed-application-profile-flags INTERFACE mbed-core-flags)
128+
129+
if("MBED_CONF_TARGET_APPLICATION_PROFILE=full" IN_LIST MBED_CONFIG_DEFINITIONS)
130+
set(application_profile_config_full TRUE)
131+
endif()
132+
if("MBED_CONF_TARGET_APPLICATION_PROFILE=bare-metal" IN_LIST MBED_CONFIG_DEFINITIONS)
133+
set(application_profile_config_baremetal TRUE)
134+
endif()
135+
if(NOT application_profile_config_full AND NOT application_profile_config_baremetal)
136+
set(application_profile_config_auto TRUE)
137+
endif()
138+
139+
if((application_profile_config_auto OR application_profile_config_full) AND
140+
(NOT MBED_GREENTEA_TEST_BAREMETAL))
141+
target_link_libraries(mbed-application-profile-flags INTERFACE mbed-rtos-flags)
142+
elseif(application_profile_config_full AND MBED_GREENTEA_TEST_BAREMETAL)
143+
message(FATAL_ERROR
144+
" Miamatched application profile config:\n"
145+
" target.application-profile: full\n"
146+
" MBED_GREENTEA_TEST_BAREMETAL: TRUE"
147+
)
148+
elseif(application_profile_config_baremetal AND NOT MBED_GREENTEA_TEST_BAREMETAL)
149+
message(FATAL_ERROR
150+
" Miamatched application profile config:\n"
151+
" target.application-profile: bare-metal\n"
152+
" MBED_GREENTEA_TEST_BAREMETAL: FALSE"
153+
)
154+
endif()
155+
124156
# Validate selected C library type
125157
# The C library type selected has to match the library that the target can support
126158
if(NOT MBED_IS_NATIVE_BUILD)

targets/targets.json5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
"semihosting-enabled": {
101101
"help": "Enable ARM Semihosting protocol. This uses a magic breakpoint instruction to enable the MCU to print data to and access files on a host machine. However, it can interfere with debuggers that are not semihost aware.",
102102
"value": false
103+
},
104+
"application-profile": {
105+
"help": "Select application profile. Options: auto, full, bare-metal.",
106+
"value": "auto"
103107
}
104108
}
105109
},

0 commit comments

Comments
 (0)