cmake: Add zephyr_libc_link_libraries function

This function allows subsystems to define libraries which get added to the
link command after all other libraries and modules. It's useful when using
a toolchain library, like libc or libgcc, as those can get added when
processing the 'lib' directory, before any module libraries and hence might
not get used to resolve symbols from modules.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2022-11-02 14:49:23 -07:00 committed by Carles Cufí
commit 87a30609da
2 changed files with 7 additions and 0 deletions

View file

@ -595,6 +595,9 @@ endforeach()
set(ZEPHYR_CURRENT_MODULE_DIR) set(ZEPHYR_CURRENT_MODULE_DIR)
set(ZEPHYR_CURRENT_CMAKE_DIR) set(ZEPHYR_CURRENT_CMAKE_DIR)
get_property(LIBC_LINK_LIBRARIES TARGET zephyr_interface PROPERTY LIBC_LINK_LIBRARIES)
zephyr_link_libraries(${LIBC_LINK_LIBRARIES})
set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h) set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h)
set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json) set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json)
set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json) set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json)

View file

@ -112,6 +112,10 @@ function(zephyr_link_libraries)
target_link_libraries(zephyr_interface INTERFACE ${ARGV}) target_link_libraries(zephyr_interface INTERFACE ${ARGV})
endfunction() endfunction()
function(zephyr_libc_link_libraries)
set_property(TARGET zephyr_interface APPEND PROPERTY LIBC_LINK_LIBRARIES ${ARGV})
endfunction()
# See this file section 3.1. target_cc_option # See this file section 3.1. target_cc_option
function(zephyr_cc_option) function(zephyr_cc_option)
foreach(arg ${ARGV}) foreach(arg ${ARGV})