Skip to main content

z_kmpkg_forward_output_variable

warning

This is an internal helper function used internally to implement kmpkg. Behavior and arguments will change in breaking ways without notice. Do not use this function.

Forward values from inner function calls into pointer out parameters through a local function scope.

Usage

z_kmpkg_forward_output_variable(<ptr_to_parent_var> <value_var>)

Parameters

<ptr_to_parent_var>

The name of a local variable set to the desired parent variable name.

Most commonly, this local is the result of a pointer-out parameter to a function.

<value_var>

The name of a local variable that will be propagated out.

Notes

The following two snippets are equivalent:

z_kmpkg_forward_output_variable(ptr_to_parent_var value_var)
if(DEFINED ptr_to_parent_var)
if(DEFINED value_var)
set("${ptr_to_parent_var}" "${value_var}" PARENT_SCOPE)
else()
unset("${ptr_to_parent_var}" PARENT_SCOPE)
endif()
endif()

Examples

function(my_function out_var)
file(SHA512 "somefile.txt" local_var)
z_kmpkg_forward_output_variable(out_var local_var)
endfunction()

Source

scripts/cmake/z_kmpkg_forward_output_variable.cmake