@@ -19,11 +19,7 @@ if (NOT COMMAND "is_int")
1919 #
2020 function (is_int target_value output )
2121 set ("${output} " false )
22-
23- # Resolve "value" from variable
24- if (DEFINED "${target_value} " )
25- set (target_value "${${target_value} }" )
26- endif ()
22+ _resolve_target_value()
2723
2824 if (target_value MATCHES "^([\-\+ ]?)([0-9]+)$" )
2925 set ("${output} " true )
@@ -45,11 +41,7 @@ if (NOT COMMAND "is_float")
4541 #
4642 function (is_float target_value output )
4743 set ("${output} " false )
48-
49- # Resolve "value" from variable
50- if (DEFINED "${target_value} " )
51- set (target_value "${${target_value} }" )
52- endif ()
44+ _resolve_target_value()
5345
5446 if (target_value MATCHES "^([\-\+ ]?)([0-9]+)\. ([0-9]+)$" )
5547 set ("${output} " true )
@@ -71,11 +63,7 @@ if (NOT COMMAND "is_numeric")
7163 #
7264 function (is_numeric target_value output )
7365 set ("${output} " false )
74-
75- # Resolve "value" from variable
76- if (DEFINED "${target_value} " )
77- set (target_value "${${target_value} }" )
78- endif ()
66+ _resolve_target_value()
7967
8068 if (target_value MATCHES "^([\-\+ ]?)([0-9]+)$" OR target_value MATCHES "^([\-\+ ]?)([0-9]+)\. ([0-9]+)$" )
8169 set ("${output} " true )
@@ -102,11 +90,7 @@ if (NOT COMMAND "is_bool")
10290 #
10391 function (is_bool target_value output )
10492 set ("${output} " false )
105-
106- # Resolve "value" from variable
107- if (DEFINED "${target_value} " )
108- set (target_value "${${target_value} }" )
109- endif ()
93+ _resolve_target_value()
11094
11195 set (accepted "true;false" )
11296 string (TOLOWER "${target_value} " target_value)
@@ -137,11 +121,7 @@ if (NOT COMMAND "is_bool_like")
137121 #
138122 function (is_bool_like target_value output )
139123 set ("${output} " false )
140-
141- # Resolve "value" from variable
142- if (DEFINED "${target_value} " )
143- set (target_value "${${target_value} }" )
144- endif ()
124+ _resolve_target_value()
145125
146126 # ...a non-zero number (including floating point numbers) is also considered
147127 # to be boolean (true).
@@ -179,11 +159,7 @@ if (NOT COMMAND "is_list")
179159 #
180160 function (is_list target_value output )
181161 set ("${output} " false )
182-
183- # Resolve "value" from variable
184- if (DEFINED "${target_value} " )
185- set (target_value "${${target_value} }" )
186- endif ()
162+ _resolve_target_value()
187163
188164 string (FIND "${target_value} " ";" has_separator)
189165 list (LENGTH target_value length )
@@ -210,11 +186,7 @@ if (NOT COMMAND "is_command")
210186 #
211187 function (is_command target_value output )
212188 set ("${output} " false )
213-
214- # Resolve "value" from variable
215- if (DEFINED "${target_value} " )
216- set (target_value "${${target_value} }" )
217- endif ()
189+ _resolve_target_value()
218190
219191 if (COMMAND "${target_value} " )
220192 set ("${output} " true )
@@ -249,11 +221,7 @@ if (NOT COMMAND "is_string")
249221 #
250222 function (is_string target_value output )
251223 set ("${output} " false )
252-
253- # Resolve "value" from variable
254- if (DEFINED "${target_value} " )
255- set (target_value "${${target_value} }" )
256- endif ()
224+ _resolve_target_value()
257225
258226 is_numeric("${target_value} " num)
259227 is_bool("${target_value} " bool )
@@ -293,11 +261,7 @@ if (NOT COMMAND "get_type")
293261 #
294262 function (get_type target_value output )
295263 set ("${output} " "undefined" )
296-
297- # Resolve "value" from variable
298- if (DEFINED "${target_value} " )
299- set (target_value "${${target_value} }" )
300- endif ()
264+ _resolve_target_value()
301265
302266 # ---------------------------------------------------------------------------------------------- #
303267
@@ -352,4 +316,25 @@ if (NOT COMMAND "get_type")
352316
353317 message (FATAL_ERROR "Unable to determine type of target value: ${target_value} " )
354318 endfunction ()
319+ endif ()
320+
321+ # -------------------------------------------------------------------------------------------------------------- #
322+ # Internals
323+ # -------------------------------------------------------------------------------------------------------------- #
324+
325+ if (NOT COMMAND "_resolve_target_value" )
326+
327+ #! _resolve_target_value : Resolves target value
328+ #
329+ # Macro (re)sets the `target_value`, if its value is a defined
330+ # variable.
331+ #
332+ # @internal
333+ #
334+ macro (_resolve_target_value)
335+ # Resolve "value" from variable
336+ if (DEFINED "${target_value} " )
337+ set (target_value "${${target_value} }" )
338+ endif ()
339+ endmacro ()
355340endif ()
0 commit comments