Remove duplicate settings when adding components
Extend AddComponent to remove duplicate values from property lists.
This makes include paths applied to the target cleaner.
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
Change-Id: I747c663d6db3a16cab713ab0ae6feb02278d9aec
diff --git a/tools/cmake/common/AddComponents.cmake b/tools/cmake/common/AddComponents.cmake
index b48f1bf..479f145 100644
--- a/tools/cmake/common/AddComponents.cmake
+++ b/tools/cmake/common/AddComponents.cmake
@@ -1,4 +1,3 @@
-#-------------------------------------------------------------------------------
# Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
@@ -56,4 +55,14 @@
include(${_file})
set(CMAKE_CONFIGURE_DEPENDS ${_file})
endforeach()
+ # Remove duplicate settings
+ foreach(_prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES
+ INTERFACE_COMPILE_DEFINITIONS COMPILE_DEFINITIONS
+ INTERFACE_COMPILE_OPTIONS COMPILE_OPTIONS
+ INTERFACE_SOURCES SOURCES
+ PUBLIC_HEADER)
+ get_property(_tmp TARGET ${MY_PARAMS_TARGET} PROPERTY ${_prop})
+ list(REMOVE_DUPLICATES _tmp)
+ set_property(TARGET ${MY_PARAMS_TARGET} PROPERTY ${_prop} ${_tmp})
+ endforeach()
endfunction()