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>
This commit is contained in:
Adrian Warecki 2023-11-06 15:04:26 +01:00 committed by Liam Girdwood
parent f3e0959472
commit 4d4421a046
2 changed files with 27 additions and 0 deletions

View File

@ -9,6 +9,11 @@ endif()
include(${CMAKE_CURRENT_LIST_DIR}/config.cmake)
# Build common module functions from sof to a static library
add_library(sof STATIC)
target_include_directories(sof PRIVATE "${SOF_BASE}/src/include")
add_subdirectory("${SOF_BASE}/src/module" module_api)
foreach(MODULE ${MODULES_LIST})
add_executable(${MODULE})
add_subdirectory(${LMDK_BASE}/modules/${MODULE} ${MODULE}_module)
@ -36,6 +41,9 @@ foreach(MODULE ${MODULES_LIST})
-P ${CMAKE_CURRENT_LIST_DIR}/ldscripts.cmake
)
# Link module with sof common module functions
target_link_libraries(${MODULE} sof)
target_link_options(${MODULE} PRIVATE
"-nostartfiles"
"-Wl,--no-undefined" "-Wl,--unresolved-symbols=report-all" "-Wl,--error-unresolved-symbols"

View File

@ -16,3 +16,22 @@ cmake_path(ABSOLUTE_PATH SOF_BASE NORMALIZE)
set(RIMAGE_INCLUDE_DIR ${SOF_BASE}/tools/rimage/src/include)
cmake_path(ABSOLUTE_PATH RIMAGE_INCLUDE_DIR NORMALIZE)
# Adds sources to target like target_sources, but assumes that
# paths are relative to subdirectory.
# Works like:
# Cmake >= 3.13:
# target_sources(<target> PRIVATE <sources>)
# Cmake < 3.13:
# target_sources(<target> PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/<sources>)
function(add_local_sources target)
foreach(arg ${ARGN})
if(IS_ABSOLUTE ${arg})
set(path ${arg})
else()
set(path ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
endif()
target_sources(${target} PRIVATE ${path})
endforeach()
endfunction()