From 8991d7ffda6c83a382d8368d07808b790b0456b7 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 17 Nov 2023 20:50:23 +0000 Subject: [PATCH] cmake: a few new add_local_sources[_ifdef]() compatibility macros For reducing CMake duplication and centralization, see #8260 Not used yet. Signed-off-by: Marc Herbert --- scripts/cmake/misc.cmake | 6 ++++++ zephyr/CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/scripts/cmake/misc.cmake b/scripts/cmake/misc.cmake index ee794780cd09..36976c119b9d 100644 --- a/scripts/cmake/misc.cmake +++ b/scripts/cmake/misc.cmake @@ -49,6 +49,12 @@ macro(is_zephyr ret) endif() endmacro() +macro(add_local_sources_ifdef condition target) + if(${condition}) + add_local_sources(${target} ${ARGN}) + endif() +endmacro() + # Adds sources to target like target_sources, but assumes that # paths are relative to subdirectory. # Works like: diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 621d9782f9cb..008d01650da9 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -128,6 +128,20 @@ macro(is_zephyr ret) endif() endmacro() +# Wrappers for re-using existing, XTOS CMake files. Do NOT use in Zephyr-specific code. +macro(add_local_sources target) + if (NOT "${target}" STREQUAL "sof") + message(FATAL_ERROR "add_local_sources() target is not 'sof'") + endif() + zephyr_library_sources(${ARGN}) +endmacro() +macro(add_local_sources_ifdef condition target) + if (NOT "${target}" STREQUAL "sof") + message(FATAL_ERROR "add_local_sources_ifdef() target is not 'sof'") + endif() + zephyr_library_sources_ifdef(${condition} ${ARGN}) +endmacro() + add_subdirectory(../src/init/ init_unused_install/) add_subdirectory(../src/ipc/ ipc_unused_install/)