Skip to content

Commit

Permalink
lmdk: Build module common functions
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
softwarecki authored and lgirdwood committed Nov 24, 2023
1 parent f3e0959 commit 4d4421a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lmdk/cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions lmdk/cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 4d4421a

Please sign in to comment.