Skip to content

Commit

Permalink
Fix linker script incorrectly selected for bare-metal profile
Browse files Browse the repository at this point in the history
mbed-os and mbed-baremetal library targets both are created, so we cannot
use if(TARGET mbed-os) or if(TARGET mbed-baremetal) to determine which one
the application target links to. Instead, determine by checking application
target's LINK_LIBRARIES property.
  • Loading branch information
ccli8 committed Sep 12, 2024
1 parent b352953 commit d26c512
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/cmake/mbed_target_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,14 @@ function(mbed_set_post_build target)
# add linker script. Skip for greentea test code, there the linker script is set in mbed_setup_linker_script()
if (NOT MBED_IS_STANDALONE)
if("${ARGN}" STREQUAL "")
if(TARGET mbed-os)
get_target_property(POST_BUILD_TARGET_LINK_LIBRARIES ${target} LINK_LIBRARIES)
if("mbed-os" IN_LIST POST_BUILD_TARGET_LINK_LIBRARIES)
get_target_property(LINKER_SCRIPT_PATH mbed-os LINKER_SCRIPT_PATH)
target_link_options(${target}
PRIVATE
"-T" "${LINKER_SCRIPT_PATH}"
)
elseif(TARGET mbed-baremetal)
elseif("mbed-baremetal" IN_LIST POST_BUILD_TARGET_LINK_LIBRARIES)
get_target_property(LINKER_SCRIPT_PATH mbed-baremetal LINKER_SCRIPT_PATH)
target_link_options(${target}
PRIVATE
Expand Down

0 comments on commit d26c512

Please sign in to comment.