CMake: Change way of 'INPUT_' values handling

Move 'INPUT_' variable detection logic out of
'qt_feature_set_cache_value' function. Use 'INPUT_'
variable to enable/disable related 'FEATURE_' in case if
'FEATURE_' is not defined.

Fixes: QTBUG-88501
Pick-to: 6.0 6.0.0
Change-Id: I1162ac0fb562036898a37b52c3f80229ec8a0970
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2020-11-18 13:17:47 +01:00
parent 08f46bb400
commit 85f0792d2b

View File

@ -171,13 +171,6 @@ function(qt_evaluate_config_expression resultVar)
endfunction()
function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
# Enable FEATURE_ variable if INPUT_ is true-like. FEATURE_ value has higher priority.
string(TOUPPER "${INPUT_${feature}}" input_value)
set(booly_values ON YES TRUE Y 1)
if ((NOT DEFINED "FEATURE_${feature}") AND (input_value IN_LIST booly_values))
set(FEATURE_${feature} ON)
endif()
if (DEFINED "FEATURE_${feature}")
# Must set up the cache
if (NOT (emit_if))
@ -207,7 +200,7 @@ function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
set("${resultVar}" "${result}" PARENT_SCOPE)
endfunction()
macro(qt_feature_set_value feature cache emit_if condition label)
macro(qt_feature_set_value feature cache condition label)
set(result "${cache}")
if (NOT (condition) AND (cache))
@ -280,8 +273,19 @@ function(qt_evaluate_feature feature)
message(FATAL_ERROR "Sanity check failed: Feature ${feature} is enabled but condition does not hold true.")
endif()
# If FEATURE_ is not defined trying to use INPUT_ variable to enable/disable feature.
if ((NOT DEFINED "FEATURE_${feature}") AND (DEFINED "INPUT_${feature}")
AND (NOT "${INPUT_${feature}}" STREQUAL "undefined")
AND (NOT "${INPUT_${feature}}" STREQUAL ""))
if(INPUT_${feature})
set(FEATURE_${feature} ON)
else()
set(FEATURE_${feature} OFF)
endif()
endif()
qt_feature_set_cache_value(cache "${feature}" "${emit_if}" "${result}" "${arg_LABEL}")
qt_feature_set_value("${feature}" "${cache}" "${emit_if}" "${condition}" "${arg_LABEL}")
qt_feature_set_value("${feature}" "${cache}" "${condition}" "${arg_LABEL}")
# Store each feature's label for summary info.
set(QT_FEATURE_LABEL_${feature} "${arg_LABEL}" CACHE INTERNAL "")