From 4a21035aa5cd4ed3629dba5f7b361ea7f5a10dec Mon Sep 17 00:00:00 2001 From: Grant Ramsay Date: Tue, 2 Jul 2024 20:53:07 +1200 Subject: [PATCH] boards: shields: Allow adding source code to shields Add shield CMakeLists.txt if it exists. Useful for one-off shields that require C code Signed-off-by: Grant Ramsay --- boards/CMakeLists.txt | 2 ++ boards/shields/CMakeLists.txt | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 boards/shields/CMakeLists.txt diff --git a/boards/CMakeLists.txt b/boards/CMakeLists.txt index 02e9e158bb8..41a6c6e6010 100644 --- a/boards/CMakeLists.txt +++ b/boards/CMakeLists.txt @@ -17,3 +17,5 @@ if(EXISTS ${BOARD_DIR}/CMakeLists.txt) add_subdirectory(${BOARD_DIR} ${build_dir}) endif() + +add_subdirectory(shields) diff --git a/boards/shields/CMakeLists.txt b/boards/shields/CMakeLists.txt new file mode 100644 index 00000000000..b1448739482 --- /dev/null +++ b/boards/shields/CMakeLists.txt @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Shield directories may contain multiple shields. Filter out duplicate +# directories to avoid including the same CMakeLists.txt file multiple times +set(unique_shield_dirs ${SHIELD_DIRS}) +list(REMOVE_DUPLICATES unique_shield_dirs) + +foreach(shield_dir ${unique_shield_dirs}) + # To avoid a lot of empty CMakeLists.txt files we assume it is not an + # error if it is missing + if(EXISTS ${shield_dir}/CMakeLists.txt) + # Out-of-tree shield directories will not be a subdirectory, + # use the filename portion of the shield directory path as a + # relative cmake binary_dir + cmake_path(GET shield_dir FILENAME binary_dir) + add_subdirectory(${shield_dir} ${binary_dir}) + endif() +endforeach()