CMake: Add handling of user-defined INPUT_foo cache variables

"configure" script translates feature-related parameters to INPUT_
variables instead of FEATURE_.

Both INPUT_ and FEATURE_ variables passed to cmake script are
equivalent. FEATURE_ has higher priority in case if both are defined.

Fixes: QTBUG-87755
Change-Id: If697a0d62ab839877a3196ea74e631582a570dda
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2020-11-03 14:08:26 +01:00
parent f8c30759d9
commit dc43061e9a
2 changed files with 11 additions and 3 deletions

View File

@ -171,14 +171,22 @@ function(qt_evaluate_config_expression resultVar)
endfunction()
function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
if (DEFINED "FEATURE_${feature}")
# Check if either FEATURE_ or INPUT_ are provided by user. INPUT_ also might be set
# when cmake is run by "configure" script.
if(DEFINED "FEATURE_${feature}")
set(feature_var "FEATURE_${feature}")
elseif(DEFINED "INPUT_${feature}" AND NOT "${INPUT_${feature}}" STREQUAL "undefined")
set(feature_var "INPUT_${feature}")
endif()
if(NOT "${feature_var}" STREQUAL "")
# Must set up the cache
if (NOT (emit_if))
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} that was not emitted was found in the CMakeCache.")
endif()
# Revisit value:
set(cache "${FEATURE_${feature}}")
set(cache "${${feature_var}}")
set(booly_values OFF NO FALSE N ON YES TRUE Y)
if ((cache IN_LIST booly_values) OR (cache GREATER_EQUAL 0))
set(result "${cache}")

View File

@ -705,7 +705,7 @@ translate_list_input(rpaths QT_EXTRA_RPATHS)
foreach(feature ${commandline_known_features})
qt_feature_normalize_name("${feature}" cmake_feature)
if(${feature} IN_LIST config_inputs)
translate_boolean_input(${feature} FEATURE_${cmake_feature})
translate_boolean_input(${feature} INPUT_${cmake_feature})
endif()
endforeach()