Debian Codegraph @

cmake/tribits/core/utils/AppendStringVar.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_guard()
11
12 include("${CMAKE_CURRENT_LIST_DIR}/ConcatStrings.cmake")
13 include("${CMAKE_CURRENT_LIST_DIR}/PrintVar.cmake")
14 include("${CMAKE_CURRENT_LIST_DIR}/TribitsDeprecatedHelpers.cmake")
15
16
17 # @FUNCTION: append_string_var()
18 #
19 # Append strings to an existing string variable (reduces boiler-place code and
20 # reduces mistakes).
21 #
22 # Usage::
23 #
24 # append_string_var(<stringVar> "<string1>" "<string2>" ...)
25 #
26 # Note that the usage of the characters ``'['``, ``']'``, ``'{'``, ``'}'`` are
27 # taken by CMake to bypass the meaning of ';' to separate string characters.
28 # If one wants to ignore the meaning of these special characters and are okay
29 # with just adding one string at a time, then use `append_string_var_ext()`_.
30 #
31 # **DEPRECATED**: Instead, use::
32 #
33 # string(APPEND <stringVar> "<string1>" "<string2>" ...)
34 #
35 function(append_string_var STRING_VAR_OUT)
36 tribits_deprecated_command(append_string_var
37 MESSAGE "Use string(APPEND) instead.")
38 #message("APPEND_STRING_VAR: ${STRING_VAR_OUT} {${ARGN}}")
39 concat_strings( STRING_VAR "${${STRING_VAR_OUT}}" ${ARGN} )
40 #print_var( STRING_VAR )
41 set(${STRING_VAR_OUT} "${STRING_VAR}" PARENT_SCOPE)
42 #print_var(STRING_VAR_OUT)
43 endfunction()
44
45
46 # @FUNCTION: append_string_var_ext()
47 #
48 # Append a single string to an existing string variable, ignoring ';' (reduces
49 # boiler-place code and reduces mistakes).
50 #
51 # Usage::
52 #
53 # append_string_var_ext(<stringVar> "<string>")
54 #
55 # Simply sets ``<stringVar> = "${<stringVar>}<string>"`` and leaves in ``';'``
56 # without creating new array elements.
57 #
58 function(append_string_var_ext STRING_VAR_OUT STRING_TO_APPEND)
59 set(STRING_VAR "${${STRING_VAR_OUT}}${STRING_TO_APPEND}")
60 set(${STRING_VAR_OUT} "${STRING_VAR}" PARENT_SCOPE)
61 endfunction()