Skip to content

Commit

Permalink
cmake: support PROPERTY argument on zephyr_link_libraries.
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit d634891)

Original-Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
GitOrigin-RevId: d634891
Cr-Build-Id: 8737279667330072001
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8737279667330072001
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: If034740a6256b303c28cf80d37a34c38be693aa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5839789
Reviewed-by: Yuval Peress <peress@google.com>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Keith Short <keithshort@chromium.org>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Tested-by: Keith Short <keithshort@chromium.org>
  • Loading branch information
tejlmand authored and Chromeos LUCI committed Sep 10, 2024
1 parent 6d3ff27 commit cb51370
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmake/modules/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cb51370

Please sign in to comment.