Debian Codegraph @

cmake/tribits/core/utils/RemoveGlobalDuplicates.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10 include(AssertDefined)
11 include(GlobalSet)
12
13
14 # @FUNCTION: remove_global_duplicates()
15 #
16 # Remove duplicate elements from a global list variable (removes boiler-plate
17 # code and errors).
18 #
19 # Usage::
20 #
21 # remove_global_duplicates(<globalVarName>)
22 #
23 # This function is necessary in order to preserve the "global" nature of the
24 # variable. If one just calls ``list(REMOVE_DUPLICATES ...)`` it will
25 # actually create a local variable of the same name and shadow the global
26 # variable! That is a fun bug to track down! The variable
27 # ``<globalVarName>`` must be defined before this function is called. If
28 # ``<globalVarName>`` is actually not a global cache variable before this
29 # function is called it will be after it completes.
30 #
31 function(remove_global_duplicates VARNAME)
32 assert_defined(${VARNAME})
33 if (${VARNAME})
34 set(TMP ${${VARNAME}})
35 list(REMOVE_DUPLICATES TMP)
36 global_set(${VARNAME} ${TMP})
37 endif()
38 endfunction()