cmake: modules: Add zephyr_library_add_dependencies extension

Add a CMake zephyr library extension for add_dependencies, similar
to the target_<func> functions.
This avoids using ${ZEPHYR_CURRENT_LIBRARY} directly.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2023-11-15 09:35:06 +01:00 committed by Carles Cufí
commit 58152eb938

View file

@ -528,6 +528,10 @@ function(zephyr_library_cc_option)
endforeach() endforeach()
endfunction() endfunction()
function(zephyr_library_add_dependencies)
add_dependencies(${ZEPHYR_CURRENT_LIBRARY} ${ARGN})
endfunction()
# Add the existing CMake library 'library' to the global list of # Add the existing CMake library 'library' to the global list of
# Zephyr CMake libraries. This is done automatically by the # Zephyr CMake libraries. This is done automatically by the
# constructor but must be called explicitly on CMake libraries that do # constructor but must be called explicitly on CMake libraries that do
@ -1819,6 +1823,12 @@ function(zephyr_linker_sources_ifdef feature_toggle)
endif() endif()
endfunction() endfunction()
function(zephyr_library_add_dependencies_ifdef feature_toggle)
if(${${feature_toggle}})
zephyr_library_add_dependencies(${ARGN})
endif()
endfunction()
macro(list_append_ifdef feature_toggle list) macro(list_append_ifdef feature_toggle list)
if(${${feature_toggle}}) if(${${feature_toggle}})
list(APPEND ${list} ${ARGN}) list(APPEND ${list} ${ARGN})
@ -1965,6 +1975,12 @@ function(zephyr_linker_sources_ifndef feature_toggle)
endif() endif()
endfunction() endfunction()
function(zephyr_library_add_dependencies_ifndef feature_toggle)
if(NOT ${feature_toggle})
zephyr_library_add_dependencies(${ARGN})
endif()
endfunction()
macro(list_append_ifndef feature_toggle list) macro(list_append_ifndef feature_toggle list)
if(NOT ${feature_toggle}) if(NOT ${feature_toggle})
list(APPEND ${list} ${ARGN}) list(APPEND ${list} ${ARGN})