From 856fadf85ca2a3b70878d01d32e4d4cef807b8a9 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 30 Mar 2021 12:37:08 +0200 Subject: [PATCH] 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 --- cmake/QtProcessConfigureArgs.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 6410fc30273..cecf7a681f8 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -43,6 +43,13 @@ else() set(commandline_files "${MODULE_ROOT}/${commandline_filename}") endif() 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(TRANSFORM configure_args STRIP) list(TRANSFORM configure_args REPLACE "\\\\" "\\\\\\\\") @@ -82,9 +89,7 @@ while(NOT "${configure_args}" STREQUAL "") elseif(arg MATCHES "^-host.*dir") message(FATAL_ERROR "${arg} is not supported anymore.") elseif(arg STREQUAL "--") - # 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}") + # Everything after this argument will be passed to CMake verbatim. list(APPEND cmake_args "${configure_args}") break() else() @@ -821,6 +826,9 @@ endif() push("${MODULE_ROOT}") +# Restore the escaped semicolons in arguments that are lists +list(TRANSFORM cmake_args REPLACE "\\[\\[;\\]\\]" "\\\\;") + execute_process(COMMAND "${CMAKE_COMMAND}" ${cmake_args} COMMAND_ECHO STDOUT RESULT_VARIABLE exit_code)