@@ -2,19 +2,21 @@ include(${CMAKE_CURRENT_LIST_DIR}/logging.cmake)
22
33# @func set_default_values(<var1> <value1> <var2> <value2> ...)
44# @brief Set default values for variables;
5- # The variable will not be overwrite if it already has a value.
5+ # The variable will not be overwrite if it already has a value.
66function (set_default_values)
77 math (EXPR ARG_COUNT "${ARGC} % 2" )
8+
89 if (NOT ${ARG_COUNT} EQUAL 0)
910 log_error("`set_default_values()` requires pairs of VAR_NAME and DEFAULT_VALUE" )
1011 endif ()
1112
1213 math (EXPR LAST_INDEX "${ARGC} - 1" )
14+
1315 foreach (IDX RANGE 0 ${LAST_INDEX} 2)
1416 math (EXPR VALUE_IDX "${IDX} + 1" )
1517 list (GET ARGV ${IDX} VAR_NAME)
1618 list (GET ARGV ${VALUE_IDX} DEFAULT_VALUE)
17-
19+
1820 if (NOT DEFINED ${VAR_NAME} )
1921 set (${VAR_NAME} ${DEFAULT_VALUE} PARENT_SCOPE)
2022 endif ()
@@ -23,10 +25,10 @@ endfunction()
2325
2426# @func try_get_value(<var> HINTS <hint1> <hint2> ...)
2527# @brief Try to assign value to <var> from hints or env:hints.
26- # $<var>_FOUND will be set to true if one of the hint found; Otherwise false.
28+ # $<var>_FOUND will be set to true if one of the hint found; Otherwise false.
2729function (try_get_value VAR)
2830 cmake_parse_arguments (PARSE_ARGV 1 ARG "" "" "HINTS" )
29-
31+
3032 # First try each hint as a CMake variable
3133 foreach (hint IN LISTS ARG_HINTS)
3234 if (DEFINED ${hint} )
@@ -35,7 +37,7 @@ function(try_get_value VAR)
3537 return ()
3638 endif ()
3739 endforeach ()
38-
40+
3941 # Then try each hint as an environment variable
4042 foreach (hint IN LISTS ARG_HINTS)
4143 if (DEFINED ENV{${hint} })
@@ -44,7 +46,7 @@ function(try_get_value VAR)
4446 return ()
4547 endif ()
4648 endforeach ()
47-
49+
4850 # If nothing found
4951 set (${VAR} "" PARENT_SCOPE)
5052 set (${VAR} _FOUND FALSE PARENT_SCOPE)
0 commit comments