Skip to content

Commit 08c2790

Browse files
committed
llext: cmake: Add support for passing more config to llext build
Pass includes, cflags, libraries and library paths to llext target. This will permit linking external libraries to llext modules. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent f7a9af1 commit 08c2790

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

zephyr/CMakeLists.txt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ previously added LLEXT module for the establishment of a dependency chain."
4848
# Build an LLEXT module. Provice a module name, a list of sources and an address
4949
# of the .text section as arguments.
5050
function(sof_llext_build module)
51-
set(multi_args SOURCES)
51+
set(multi_args SOURCES INCLUDES CFLAGS LIBS LIBS_PATH)
5252
set(single_args LIB)
5353
cmake_parse_arguments(PARSE_ARGV 1 SOF_LLEXT "${options}" "${single_args}" "${multi_args}")
5454

@@ -69,6 +69,22 @@ function(sof_llext_build module)
6969
"${SOF_BASE}/tools/rimage/src/include"
7070
)
7171

72+
target_include_directories(${module}_llext_lib PRIVATE
73+
"${SOF_LLEXT_INCLUDES}"
74+
)
75+
76+
target_compile_options(${module}_llext_lib PRIVATE
77+
"${SOF_LLEXT_CFLAGS}"
78+
)
79+
80+
target_link_libraries(${module}_llext_lib PRIVATE
81+
"${SOF_LLEXT_LIBS}"
82+
)
83+
84+
foreach(lib ${SOF_LLEXT_LIBS})
85+
set(EXTRA_LIBS ${EXTRA_LIBS} -l${lib})
86+
endforeach()
87+
7288
sof_append_relative_path_definitions(${module}_llext_lib)
7389

7490
add_llext_command(TARGET ${module}
@@ -86,6 +102,11 @@ function(sof_llext_build module)
86102
set(EXTRA_LINKER_PARAMS -nostdlib -nodefaultlibs -shared)
87103
endif()
88104

105+
foreach(path ${SOF_LLEXT_LIBS_PATH})
106+
llext_link_options(${module} -L${path})
107+
set(EXTRA_LINKER_PARAMS ${EXTRA_LINKER_PARAMS} -L${path})
108+
endforeach()
109+
89110
get_target_property(proc_in_file ${module} lib_output)
90111
get_target_property(proc_out_file ${module} pkg_input)
91112
get_target_property(proc_pkg_file ${module} pkg_output)
@@ -109,7 +130,7 @@ function(sof_llext_build module)
109130
--text-addr=${CONFIG_LIBRARY_BASE_ADDRESS}
110131
-c $<TARGET_PROPERTY:bintools,elfconvert_command>
111132
-f ${proc_in_file} -o ${proc_out_file} ${CMAKE_C_COMPILER} --
112-
${EXTRA_LINKER_PARAMS} $<TARGET_OBJECTS:${module}_llext_lib>
133+
${EXTRA_LINKER_PARAMS} $<TARGET_OBJECTS:${module}_llext_lib> ${EXTRA_LIBS}
113134
)
114135

115136
add_llext_command(TARGET ${module}

0 commit comments

Comments
 (0)