Add support for _qt_internal_configure_file(GENERATE ... INPUT

Allow generating files from template file. The signature first
expands the '@' wrapped variables in template file and then generates
the resulting file using file(GENERATE command.

Pick-to: 6.8 6.9
Change-Id: I0b4cf557da1d5161ffcde1c44aea98c440427980
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2025-04-22 10:57:33 +02:00
parent 4280d97719
commit 5c30ae2c9f

View File

@ -880,12 +880,12 @@ function(_qt_internal_configure_file mode)
# the generator expressions evaluation inside the resulting CONTENT. # the generator expressions evaluation inside the resulting CONTENT.
if(mode STREQUAL "GENERATE") if(mode STREQUAL "GENERATE")
if(arg_INPUT) if(arg_INPUT)
# This is not a limitation of any kind, simply is not required at configure_file("${arg_INPUT}" "${arg_OUTPUT}.tmp" @ONLY)
# implementation time. Feel free to extend. file(GENERATE OUTPUT "${arg_OUTPUT}" INPUT "${arg_OUTPUT}.tmp")
message(FATAL_ERROR "GENERATE mode doesn't support INPUT argument.") else()
endif()
string(CONFIGURE "${arg_CONTENT}" arg_CONTENT @ONLY) string(CONFIGURE "${arg_CONTENT}" arg_CONTENT @ONLY)
file(GENERATE OUTPUT "${arg_OUTPUT}" CONTENT "${arg_CONTENT}") file(GENERATE OUTPUT "${arg_OUTPUT}" CONTENT "${arg_CONTENT}")
endif()
return() return()
endif() endif()