Skip to content

Commit 330d73e

Browse files
marc-hblgirdwood
authored andcommitted
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>
1 parent 98d5efc commit 330d73e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

scripts/cmake/misc.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ macro(is_zephyr ret)
4949
endif()
5050
endmacro()
5151

52+
# This macro
53+
# - saves a LOT of repetition, and
54+
# - mimics Zephyr, which helps with compatibility.
55+
macro(add_local_sources_ifdef condition target)
56+
if(${condition})
57+
add_local_sources(${target} ${ARGN})
58+
endif()
59+
endmacro()
60+
5261
# Adds sources to target like target_sources, but assumes that
5362
# paths are relative to subdirectory.
5463
# Works like:

zephyr/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ macro(is_zephyr ret)
128128
endif()
129129
endmacro()
130130

131+
# Wrappers for compatibility and re-use of existing, XTOS CMake files.
132+
# Do NOT use these macros in this file or in any other Zephyr-specific
133+
# CMake code.
134+
macro(add_local_sources target)
135+
if (NOT "${target}" STREQUAL "sof")
136+
message(FATAL_ERROR "add_local_sources() target is not 'sof'")
137+
endif()
138+
zephyr_library_sources(${ARGN})
139+
endmacro()
140+
macro(add_local_sources_ifdef condition target)
141+
if (NOT "${target}" STREQUAL "sof")
142+
message(FATAL_ERROR "add_local_sources_ifdef() target is not 'sof'")
143+
endif()
144+
zephyr_library_sources_ifdef(${condition} ${ARGN})
145+
endmacro()
146+
131147
add_subdirectory(../src/init/ init_unused_install/)
132148
add_subdirectory(../src/ipc/ ipc_unused_install/)
133149

0 commit comments

Comments
 (0)