Skip to content

Commit 8fcf316

Browse files
committed
cmake/zephyr: unify cmake rules for src/samples
Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/samples/ instead. Link: #8260 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent e5ad7f6 commit 8fcf316

2 files changed

Lines changed: 15 additions & 35 deletions

File tree

src/samples/audio/CMakeLists.txt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# SPDX-License-Identifier: BSD-3-Clause
2-
if(CONFIG_SAMPLE_SMART_AMP)
3-
if(CONFIG_IPC_MAJOR_3)
4-
add_local_sources(sof
5-
smart_amp_test_ipc3.c
6-
)
7-
elseif(CONFIG_IPC_MAJOR_4)
8-
add_local_sources(sof
9-
smart_amp_test_ipc4.c
10-
)
11-
endif()
2+
3+
if(CONFIG_IPC_MAJOR_3)
4+
set(ipc_suffix ipc3)
5+
elseif(CONFIG_IPC_MAJOR_4)
6+
set(ipc_suffix ipc4)
7+
endif()
8+
9+
if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m")
10+
add_subdirectory(smart_amp_test_llext ${PROJECT_BINARY_DIR}/smart_amp_test_llext)
11+
add_dependencies(app smart_amp_test)
12+
elseif(CONFIG_SAMPLE_SMART_AMP)
13+
add_local_sources(sof smart_amp_test_${ipc_suffix}.c)
1214
endif()
1315

1416
if(CONFIG_SAMPLE_KEYPHRASE)
15-
add_local_sources(sof
16-
detect_test.c
17-
)
17+
add_local_sources(sof detect_test.c)
1818
endif()
1919

2020
if(CONFIG_KWD_NN_SAMPLE_KEYPHRASE)
21-
add_local_sources(sof kwd_nn_detect_test.c)
21+
add_local_sources(sof kwd_nn_detect_test.c)
2222
endif()

zephyr/CMakeLists.txt

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ cmake_path(SET sof_top_dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/..")
134134
set(SOF_SRC_PATH "${sof_top_dir}/src")
135135

136136
set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform")
137-
set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples")
138137
set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers")
139138
set(SOF_TRACE_PATH "${SOF_SRC_PATH}/trace")
140139

@@ -211,6 +210,7 @@ add_subdirectory(../src/ipc/ ipc_unused_install/)
211210
add_subdirectory(../src/lib/ lib_unused_install/)
212211
add_subdirectory(../src/library_manager/ library_manager_unused_install/)
213212
add_subdirectory(../src/logging/ logging_unused_install/)
213+
add_subdirectory(../src/samples/ samples_unused_install/)
214214
add_subdirectory(../src/schedule/ schedule_unused_install/)
215215
add_subdirectory(../src/trace/ trace_unused_install/)
216216
add_subdirectory(test/)
@@ -481,26 +481,6 @@ zephyr_library_sources_ifdef(CONFIG_FAST_GET lib/fast-get.c)
481481

482482
# Optional SOF sources - depends on Kconfig - WIP
483483

484-
if(CONFIG_IPC_MAJOR_3)
485-
set(ipc_suffix ipc3)
486-
elseif(CONFIG_IPC_MAJOR_4)
487-
set(ipc_suffix ipc4)
488-
endif()
489-
490-
zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE
491-
${SOF_SAMPLES_PATH}/audio/detect_test.c
492-
)
493-
494-
if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m")
495-
add_subdirectory(${SOF_SAMPLES_PATH}/audio/smart_amp_test_llext
496-
${PROJECT_BINARY_DIR}/smart_amp_test_llext)
497-
add_dependencies(app smart_amp_test)
498-
elseif(CONFIG_SAMPLE_SMART_AMP)
499-
zephyr_library_sources(
500-
${SOF_SAMPLES_PATH}/audio/smart_amp_test_${ipc_suffix}.c
501-
)
502-
endif()
503-
504484
if(CONFIG_PROBE STREQUAL "m")
505485
add_subdirectory(${SOF_SRC_PATH}/probe/llext
506486
${PROJECT_BINARY_DIR}/probe_llext)

0 commit comments

Comments
 (0)