cmake: support PROPERTY argument on zephyr_link_libraries.

To ease the use of linker flag properties and to simplify the use of
generator expression then an optional PROPERTY argument has been added
to the zephyr_link_libraries() function.

This means a call such as:
zephyr_link_libraries($<TARGET_PROPERTY:linker,<property-name>)
can instead be simplified to:
zephyr_link_libraries(PROPERTY <property-name>)

Thus making intention clearer and keeping the complexity and minimizes
the risk of typos when writing generator expressions.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2024-09-02 10:18:55 +02:00 committed by Carles Cufí
commit d63489195f

View file

@ -113,7 +113,14 @@ endfunction()
# https://cmake.org/cmake/help/latest/command/target_link_libraries.html
function(zephyr_link_libraries)
target_link_libraries(zephyr_interface INTERFACE ${ARGV})
if(ARGV0 STREQUAL "PROPERTY")
if(ARGC GREATER 2)
message(FATAL_ERROR "zephyr_link_libraries(PROPERTY <prop>) only allows a single property.")
endif()
target_link_libraries(zephyr_interface INTERFACE $<TARGET_PROPERTY:linker,${ARGV1}>)
else()
target_link_libraries(zephyr_interface INTERFACE ${ARGV})
endif()
endfunction()
function(zephyr_libc_link_libraries)