cmake: yaml: update timestamp on intermediate file save

file(GENERATE ...) does not update the output file if the content is
unchanged. Since the metadata in build_info.yml mostly depends on the
build configuration, the timestamp of the intermediate file does not get
updated on most rebuilds, while the final file does, due to immediate
file(WRITE ...) calls. Since the latter is newer, no post-process step
is executed and the file is left with commented genexes.

Touching the intermediate file ensures that the post-process step is
performed every time, even if the content is unchanged, restoring the
expected behavior.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
Luca Burelli 2025-04-10 10:13:30 +02:00 committed by Benjamin Cabé
parent 6c9e478e49
commit 0f71880001

View File

@ -534,6 +534,7 @@ function(yaml_save)
to_yaml("${json_content}" 0 yaml_out TEMP_GENEX)
FILE(GENERATE OUTPUT ${expanded_file} CONTENT "${yaml_out}")
FILE(TOUCH ${expanded_file}) # ensure timestamp is updated even if nothing changed
endif()
endfunction()