From c11beb8d324ca7800e92e051f8a309072ac22434 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 11 Mar 2024 14:09:01 +0100 Subject: [PATCH] configure: Fix -c++std and -sanitize options This amends commit 110f656da9e9b2511c89679e79b197a3e7b07393. Command line options with a TYPE that denotes a custom command line argument handler cannot set a feature "foo" anymore by just setting INPUT_foo to "yes". Instead, they must use the newly introduced functions qtConfCommandlineEnableFeature and qtConfCommandlineDisableFeature. These functions will set INPUT_foo and augment the input with the information "this input is of boolean type". This information is used when deciding whether to use this input as feature switch. Change-Id: I83c691cc57424159148f059c2a1c8cd72e39ee63 Reviewed-by: Alexandru Croitor --- cmake/QtProcessConfigureArgs.cmake | 22 +++++++++++++++++++++- qt_cmdline.cmake | 18 +++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 5e2b92a19cf..2080d3222a0 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -287,7 +287,7 @@ function(qt_commandline_option name) set(input_name ${arg_NAME}) set(commandline_option_${name}_variable "${arg_NAME}" PARENT_SCOPE) endif() - set(commandline_input_${input_name}_type "${arg_TYPE}" PARENT_SCOPE) + set_property(GLOBAL PROPERTY INPUTTYPE_${input_name} "${arg_TYPE}") if(NOT "${arg_VALUE}" STREQUAL "") set(commandline_option_${name}_value "${arg_VALUE}" PARENT_SCOPE) endif() @@ -378,6 +378,23 @@ function(qtConfCommandlineAppendInput name val) qtConfCommandlineSetInput(${name} "${val}") endfunction() +function(qtConfCommandlineSetInputType input_name type_name) + set_property(GLOBAL PROPERTY INPUTTYPE_${input_name} "${type_name}") +endfunction() + +function(qtConfCommandlineSetBooleanInput name val) + qtConfCommandlineSetInput(${name} ${val}) + qtConfCommandlineSetInputType(${name} boolean) +endfunction() + +function(qtConfCommandlineEnableFeature name) + qtConfCommandlineSetBooleanInput(${name} yes) +endfunction() + +function(qtConfCommandlineDisableFeature name) + qtConfCommandlineSetBooleanInput(${name} no) +endfunction() + function(qtConfValidateValue opt val out_var) set(${out_var} TRUE PARENT_SCOPE) @@ -753,6 +770,9 @@ get_property(config_inputs GLOBAL PROPERTY CONFIG_INPUTS) list(REMOVE_DUPLICATES config_inputs) foreach(var ${config_inputs}) get_property(INPUT_${var} GLOBAL PROPERTY INPUT_${var}) + if("${commandline_input_type}" STREQUAL "") + get_property(commandline_input_${var}_type GLOBAL PROPERTY INPUTTYPE_${var}) + endif() endforeach() macro(drop_input name) diff --git a/qt_cmdline.cmake b/qt_cmdline.cmake index fa398c6d025..5e7cc32356c 100644 --- a/qt_cmdline.cmake +++ b/qt_cmdline.cmake @@ -145,11 +145,11 @@ function(qt_commandline_cxxstd arg val nextok) return() endif() if(val MATCHES "(c\\+\\+)?(20|2a)") - qtConfCommandlineSetInput(c++20 yes) - qtConfCommandlineSetInput(c++2b no) + qtConfCommandlineEnableFeature(c++20) + qtConfCommandlineDisableFeature(c++2b) elseif(val MATCHES "(c\\+\\+)?(2b)") - qtConfCommandlineSetInput(c++20 yes) - qtConfCommandlineSetInput(c++2b yes) + qtConfCommandlineEnableFeature(c++20) + qtConfCommandlineEnableFeature(c++2b) else() qtConfAddError("Invalid argument '${val}' to command line parameter '${arg}'") endif() @@ -164,15 +164,15 @@ function(qt_commandline_sanitize arg val nextok) return() endif() if(val STREQUAL "address") - qtConfCommandlineSetInput(sanitize_address yes) + qtConfCommandlineEnableFeature(sanitize_address) elseif(val STREQUAL "thread") - qtConfCommandlineSetInput(sanitize_thread yes) + qtConfCommandlineEnableFeature(sanitize_thread) elseif(val STREQUAL "memory") - qtConfCommandlineSetInput(sanitize_memory yes) + qtConfCommandlineEnableFeature(sanitize_memory) elseif(val STREQUAL "fuzzer-no-link") - qtConfCommandlineSetInput(sanitize_fuzzer_no_link yes) + qtConfCommandlineEnableFeature(sanitize_fuzzer_no_link) elseif(val STREQUAL "undefined") - qtConfCommandlineSetInput(sanitize_undefined yes) + qtConfCommandlineEnableFeature(sanitize_undefined) else() qtConfAddError("Invalid argument '${val}' to command line parameter '${arg}'") endif()