mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
feat(cmakev2/utilities): add file_generate function
The file_generate function is used by some existing components, so it should be added to cmakev2 as well. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -563,3 +563,30 @@ function(fail_target target_name message_line0)
|
||||
${CMAKE_COMMAND} -P ${idf_path}/tools/cmake/scripts/fail.cmake
|
||||
VERBATIM)
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
file_generate(<output>
|
||||
[INPUT <file>]
|
||||
[CONTENT <string>])
|
||||
|
||||
:output[in]: Output file name.
|
||||
:INPUT[in]: Input file name.
|
||||
:CONTENT[in]: Input string.
|
||||
|
||||
Utility to generate file and have the output automatically added to cleaned
|
||||
files.
|
||||
#]]
|
||||
function(file_generate output)
|
||||
cmake_parse_arguments(_ "" "INPUT;CONTENT" "" ${ARGN})
|
||||
|
||||
if(__INPUT)
|
||||
file(GENERATE OUTPUT "${output}" INPUT "${__INPUT}")
|
||||
elseif(__CONTENT)
|
||||
file(GENERATE OUTPUT "${output}" CONTENT "${__CONTENT}")
|
||||
else()
|
||||
message(FATAL_ERROR "Content to generate not specified.")
|
||||
endif()
|
||||
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${output}")
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user