feat(cmakev2/utilities): add idf_target_post_build_msg helper

Add a helper function for printing multi-line post-build messages on a
target. The message lines are joined with newlines, written to a file at
configure time, and printed at build time using a single cmake -E cat
command, replacing the need for repeated cmake -E echo invocations.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
Frantisek Hrbata
2026-03-27 19:18:11 +08:00
committed by BOT
parent 6b8aa157e5
commit ba4c6de807
+25
View File
@@ -683,6 +683,31 @@ function(add_prefix var prefix)
set(${var} "${newlist}" PARENT_SCOPE)
endfunction()
#[[
idf_target_post_build_msg(<target> <line>...)
*target[in]*
Target to attach the post-build message to.
*line[in]*
Message lines to print after the target is built.
Add a post-build step to ``<target>`` that prints the given message lines.
The lines are joined with newlines, written to a file at configure time,
and printed at build time using a single ``cmake -E cat`` command.
#]]
function(idf_target_post_build_msg target)
string(MD5 hash "${ARGN}")
set(msg_file "${CMAKE_CURRENT_BINARY_DIR}/_post_build_msg_${target}_${hash}.txt")
list(JOIN ARGN "\n" msg)
file(WRITE "${msg_file}" "${msg}\n")
add_custom_command(TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E cat "${msg_file}"
VERBATIM)
endfunction()
#[[
fail_target(<target> <line0> [<line>...])