1# SPDX-License-Identifier: Apache-2.0
2
3# Shield directories may contain multiple shields. Filter out duplicate
4# directories to avoid including the same CMakeLists.txt file multiple times
5set(unique_shield_dirs ${SHIELD_DIRS})
6list(REMOVE_DUPLICATES unique_shield_dirs)
7
8foreach(shield_dir ${unique_shield_dirs})
9  # To avoid a lot of empty CMakeLists.txt files we assume it is not an
10  # error if it is missing
11  if(EXISTS ${shield_dir}/CMakeLists.txt)
12    # Out-of-tree shield directories will not be a subdirectory,
13    # use the filename portion of the shield directory path as a
14    # relative cmake binary_dir
15    cmake_path(GET shield_dir FILENAME binary_dir)
16    add_subdirectory(${shield_dir} ${binary_dir})
17  endif()
18endforeach()
19