Skip to content

Commit e21e8d3

Browse files
committed
lmdk: Build module common functions
Added building a static library containing common functions for modules provided by sof. Native loadable modules are statically linked to it. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
1 parent be0f5fb commit e21e8d3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lmdk/cmake/build.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ endif()
99

1010
include(${CMAKE_CURRENT_LIST_DIR}/config.cmake)
1111

12+
# Build common module functions from sof to a static library
13+
add_library(sof STATIC)
14+
target_include_directories(sof PRIVATE "${SOF_BASE}/src/include")
15+
add_subdirectory("${SOF_BASE}/src/module" module_api)
16+
1217
foreach(MODULE ${MODULES_LIST})
1318
add_executable(${MODULE})
1419
add_subdirectory(${LMDK_BASE}/modules/${MODULE} ${MODULE}_module)
@@ -36,6 +41,9 @@ foreach(MODULE ${MODULES_LIST})
3641
-P ${CMAKE_CURRENT_LIST_DIR}/ldscripts.cmake
3742
)
3843

44+
# Link module with sof common module functions
45+
target_link_libraries(${MODULE} sof)
46+
3947
target_link_options(${MODULE} PRIVATE
4048
"-nostartfiles"
4149
"-Wl,--no-undefined" "-Wl,--unresolved-symbols=report-all" "-Wl,--error-unresolved-symbols"

lmdk/cmake/config.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,22 @@ cmake_path(ABSOLUTE_PATH SOF_BASE NORMALIZE)
1616

1717
set(RIMAGE_INCLUDE_DIR ${SOF_BASE}/tools/rimage/src/include)
1818
cmake_path(ABSOLUTE_PATH RIMAGE_INCLUDE_DIR NORMALIZE)
19+
20+
# Adds sources to target like target_sources, but assumes that
21+
# paths are relative to subdirectory.
22+
# Works like:
23+
# Cmake >= 3.13:
24+
# target_sources(<target> PRIVATE <sources>)
25+
# Cmake < 3.13:
26+
# target_sources(<target> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/<sources>)
27+
function(add_local_sources target)
28+
foreach(arg ${ARGN})
29+
if(IS_ABSOLUTE ${arg})
30+
set(path ${arg})
31+
else()
32+
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
33+
endif()
34+
35+
target_sources(${target} PRIVATE ${path})
36+
endforeach()
37+
endfunction()

0 commit comments

Comments
 (0)