fix(cmakev2/utilities): respect CMake's regular variables in __get_default_value

Currently, only the value stored in CMake's cache is considered when
setting the default value. Allow regular variables as well, which may be
set in the project's CMakeLists.txt file.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2025-08-05 13:16:33 +02:00
committed by BOT
parent 72d4fecfa9
commit 11dba11e36

View File

@@ -178,7 +178,7 @@ endfunction()
order of precedence, with the first having the highest precedence.
1. environmental variable
2. CMake cache variable
2. CMake variable or value stored in CMake's cache
3. ``<value>`` as specified with the ``DEFAULT`` option
#]]
function(__get_default_value)
@@ -202,8 +202,8 @@ function(__get_default_value)
if(DEFINED ENV{${ARG_VARIABLE}})
set(value "$ENV{${ARG_VARIABLE}}")
elseif(DEFINED CACHE{${ARG_VARIABLE}})
set(value "$CACHE{${ARG_VARIABLE}}")
elseif(DEFINED ${ARG_VARIABLE})
set(value "${${ARG_VARIABLE}}")
else()
set(value "${ARG_DEFAULT}")
endif()