Fix processing of list arguments passed to the 'configure' script

list(TRANSFORM ...) unexpectedly removes semicolon escaping in list
items. So the list arguments seems to be broken. The 'bracket argument'
suppresses this behavior. Right before forwarding command line
arguments to the cmake call, 'bracket arguments'are replaced by escaped
semicolons back.

Recent fix escapes all semicolons of the 'configure_args' and glues
all arguments to a single 'list'.

Amends df8e1c8e588cb0529b2bc02faef1022ef3f29145

Change-Id: I4a458b9e3add307b36924c4c7c7f739d348f9343
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2021-03-30 12:37:08 +02:00
parent 9466b3629a
commit 856fadf85c

View File

@ -43,6 +43,13 @@ else()
set(commandline_files "${MODULE_ROOT}/${commandline_filename}") set(commandline_files "${MODULE_ROOT}/${commandline_filename}")
endif() endif()
file(STRINGS "${OPTFILE}" configure_args) file(STRINGS "${OPTFILE}" configure_args)
# list(TRANSFORM ...) unexpectedly removes semicolon escaping in list items. So the list arguments
# seem to be broken. The 'bracket argument' suppresses this behavior. Right before forwarding
# command line arguments to the cmake call, 'bracket arguments' are replaced by escaped semicolons
# back.
list(TRANSFORM configure_args REPLACE ";" "[[;]]")
list(FILTER configure_args EXCLUDE REGEX "^[ \t]*$") list(FILTER configure_args EXCLUDE REGEX "^[ \t]*$")
list(TRANSFORM configure_args STRIP) list(TRANSFORM configure_args STRIP)
list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\") list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\")
@ -82,9 +89,7 @@ while(NOT "${configure_args}" STREQUAL "")
elseif(arg MATCHES "^-host.*dir") elseif(arg MATCHES "^-host.*dir")
message(FATAL_ERROR "${arg} is not supported anymore.") message(FATAL_ERROR "${arg} is not supported anymore.")
elseif(arg STREQUAL "--") elseif(arg STREQUAL "--")
# Everything after this argument will be passed to CMake verbatim, # Everything after this argument will be passed to CMake verbatim.
# but we need to escape semi-colons so that lists are preserved.
string(REPLACE ";" "\\;" configure_args "${configure_args}")
list(APPEND cmake_args "${configure_args}") list(APPEND cmake_args "${configure_args}")
break() break()
else() else()
@ -821,6 +826,9 @@ endif()
push("${MODULE_ROOT}") push("${MODULE_ROOT}")
# Restore the escaped semicolons in arguments that are lists
list(TRANSFORM cmake_args REPLACE "\\[\\[;\\]\\]" "\\\\;")
execute_process(COMMAND "${CMAKE_COMMAND}" ${cmake_args} execute_process(COMMAND "${CMAKE_COMMAND}" ${cmake_args}
COMMAND_ECHO STDOUT COMMAND_ECHO STDOUT
RESULT_VARIABLE exit_code) RESULT_VARIABLE exit_code)