native simulator: Add property to collect libraries to link w runner

Add a property to the native_simulator target, to collect
the libraries we want to link with the runner, instead of
abusing the link options to pass them.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-08-24 12:55:53 +02:00 committed by Fabio Baltieri
commit b021c7611d
2 changed files with 5 additions and 0 deletions

View file

@ -19,6 +19,9 @@ endif()
# For ex. target_sources(native_simulator INTERFACE silly.c) # For ex. target_sources(native_simulator INTERFACE silly.c)
# Note that these are built with the host libC and the include directories # Note that these are built with the host libC and the include directories
# the runner is built with. # the runner is built with.
# RUNNER_LINK_LIBRARIES:
# Extra libraries to link with the runner
# For ex. set_property(TARGET native_simulator APPEND PROPERTY RUNNER_LINK_LIBRARIES "mylib.a")
# Note: target_link_libraries() cannot be used on this library at this point. # Note: target_link_libraries() cannot be used on this library at this point.
# target_link_libraries() updates INTERFACE_LINK_LIBRARIES but wrapping it with extra # target_link_libraries() updates INTERFACE_LINK_LIBRARIES but wrapping it with extra
# information. This means we cannot directly pass it to the native_simulator runner build. # information. This means we cannot directly pass it to the native_simulator runner build.
@ -26,6 +29,7 @@ endif()
# info. # info.
# We use target_link_options() instead # We use target_link_options() instead
add_library(native_simulator INTERFACE) add_library(native_simulator INTERFACE)
set_property(TARGET native_simulator PROPERTY RUNNER_LINK_LIBRARIES "")
set(NSI_DIR ${ZEPHYR_BASE}/scripts/native_simulator CACHE PATH "Path to the native simulator") set(NSI_DIR ${ZEPHYR_BASE}/scripts/native_simulator CACHE PATH "Path to the native simulator")

View file

@ -14,6 +14,7 @@ set(nsi_config_content
"NSI_EXE:=${zephyr_build_path}/${KERNEL_EXE_NAME}" "NSI_EXE:=${zephyr_build_path}/${KERNEL_EXE_NAME}"
"NSI_EXTRA_SRCS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,INTERFACE_SOURCES>,\ >" "NSI_EXTRA_SRCS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,INTERFACE_SOURCES>,\ >"
"NSI_LINK_OPTIONS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,INTERFACE_LINK_OPTIONS>,\ >" "NSI_LINK_OPTIONS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,INTERFACE_LINK_OPTIONS>,\ >"
"NSI_EXTRA_LIBS:=$<JOIN:$<TARGET_PROPERTY:native_simulator,RUNNER_LINK_LIBRARIES>,\ >"
"NSI_PATH:=${NSI_DIR}/" "NSI_PATH:=${NSI_DIR}/"
) )