Remember

cache_remember() is responsible for retrieve cached entry if it exists, or invoke callback and cache resulting output value of the callback.

The following parameters are accepted:

  • KEY: _ The variable to assign and cache._
  • CALLBACK: _ The function or macro that returns value to be cached, if KEY hasn’t already been cached._
  • TTL: (optional), Time-To-Live of cache entry in seconds (see TTL for details).
  • TYPE: (optional), Cmake cache entry type, BOOL, STRING,…etc. Defaults to STRING if not specified.
  • DESCRIPTION: (optional), Description of cache entry.

Example

function(make_asset_uuid output)
    # ...complex logic for generating a UUID... (not shown here)...
    set("${output}" "...")
    
    # Assign to "output" variable
    return(PROPAGATE "${output}")
endfunction()

cache_remember(
    KEY assert_uuid
    CALLBACK "make_asset_uuid"
)

message("${assert_uuid}") # E.g. 2786d7fb-6d88-4878-b1f6-4c66cee31700