Skip to content

Commit

Permalink
cmake: a few new add_local_sources[_ifdef]() compatibility macros
Browse files Browse the repository at this point in the history
For reducing CMake duplication and centralization, see thesofproject#8260

Not used yet.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
  • Loading branch information
marc-hb committed Nov 18, 2023
1 parent 2bfdd7a commit 8991d7f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/cmake/misc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down

0 comments on commit 8991d7f

Please sign in to comment.