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 <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2023-11-17 20:50:23 +00:00 committed by Liam Girdwood
parent 98d5efc3a7
commit 330d73eec1
2 changed files with 25 additions and 0 deletions

View File

@ -49,6 +49,15 @@ macro(is_zephyr ret)
endif()
endmacro()
# This macro
# - saves a LOT of repetition, and
# - mimics Zephyr, which helps with compatibility.
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:

View File

@ -128,6 +128,22 @@ macro(is_zephyr ret)
endif()
endmacro()
# Wrappers for compatibility and re-use of existing, XTOS CMake files.
# Do NOT use these macros in this file or in any other Zephyr-specific
# CMake 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/)