From faa06fc6f5853fd1997b71c886bf7a3de9ce9c22 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 22 Dec 2023 13:08:54 +0100 Subject: [PATCH] configure: Convert -feature-* arguments to -DFEATURE_foo CMake args We now convert the configure arguments -feature-foo and -no-feature-foo to the CMake arguments -DFEATURE_foo=ON and -DFEATURE_foo=OFF. This is done, because the former behavior was surprising, and it allows us to remove quite some code that was needed to calculate feature values from INPUT_foo and FEATURE_foo. Task-number: QTBUG-120529 Change-Id: I94f8eb4adbbcaa1090aedce6e711012781c62a3c Reviewed-by: Alexey Edelev --- cmake/QtProcessConfigureArgs.cmake | 36 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 9c86d08c258..bc776b4b18f 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -85,6 +85,7 @@ list(TRANSFORM configure_args STRIP) unset(generator) set(auto_detect_compiler TRUE) set(auto_detect_generator ${qtbase_or_top_level_build}) +set(no_prefix_option FALSE) unset(device_options) unset(options_json_file) set_property(GLOBAL PROPERTY UNHANDLED_ARGS "") @@ -127,8 +128,10 @@ while(NOT "${configure_args}" STREQUAL "") push("-DINSTALL_MKSPECSDIR=${path}") elseif(arg STREQUAL "-developer-build") set(developer_build TRUE) - # Treat this argument as "unhandled" to process it further. - set_property(GLOBAL APPEND PROPERTY UNHANDLED_ARGS "${arg}") + push("-DFEATURE_developer_build=ON") + elseif(arg STREQUAL "-no-prefix") + set(no_prefix_option TRUE) + push("-DFEATURE_no_prefix=ON") elseif(arg STREQUAL "-cmake-file-api") set(cmake_file_api TRUE) elseif(arg STREQUAL "-no-cmake-file-api") @@ -664,10 +667,20 @@ while(1) if(arg MATCHES "^--?enable-(.*)") set(opt "${CMAKE_MATCH_1}") set(val "yes") - # Handle -no-prefix so it's not interpreted as the negation of -prefix - elseif(arg MATCHES "-(no-prefix)") - set(opt "${CMAKE_MATCH_1}") - set(val "") + # Handle builtin [-no]-feature-xxx + elseif(arg MATCHES "^--?(no-)?feature-(.*)") + set(opt "${CMAKE_MATCH_2}") + if(NOT opt IN_LIST commandline_known_features) + qtConfAddError("Enabling/Disabling unknown feature '${opt}'.") + endif() + if("${CMAKE_MATCH_1}" STREQUAL "") + set(val "ON") + else() + set(val "OFF") + endif() + qt_feature_normalize_name("${opt}" normalized_feature_name) + push(-DFEATURE_${normalized_feature_name}=${val}) + continue() elseif(arg MATCHES "^--?(disable|no)-(.*)") set(opt "${CMAKE_MATCH_2}") set(val "no") @@ -704,15 +717,6 @@ while(1) endforeach() endif() - # Handle builtin [-no]-feature-xxx - if("${type}" STREQUAL "" AND opt MATCHES "^feature-(.*)") - set(opt "${CMAKE_MATCH_1}") - if(NOT opt IN_LIST commandline_known_features) - qtConfAddError("Enabling/Disabling unknown feature '${opt}'.") - endif() - set(type boolean) - endif() - if("${type}" STREQUAL "") qtConfAddError("Unknown command line option '${arg}'.") endif() @@ -995,7 +999,7 @@ foreach(input ${config_inputs}) push("-DINPUT_${cmake_input}=${INPUT_${input}}") endforeach() -if(DEFINED INPUT_no-prefix AND DEFINED INPUT_prefix) +if(no_prefix_option AND DEFINED INPUT_prefix) qtConfAddError("Can't specify both -prefix and -no-prefix options at the same time.") endif()