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 <alexey.edelev@qt.io>
This commit is contained in:
Joerg Bornemann 2023-12-22 13:08:54 +01:00
parent 38de2c9532
commit faa06fc6f5

View File

@ -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()