CMake: Rework INPUT_ variables handling
INPUT_ variables enable FEATURE_ variable only in case if valid "true"-like value is assigned from command line. Amends dc43061e9abb15bc07eb236f5344c79d27590812 Fixes: QTBUG-87755 Task-number: QTBUG-88142 Change-Id: I65e85c7548981fdec94366b531f6df6396be71b7 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
501f27b5c6
commit
aa6ad15424
@ -171,24 +171,23 @@ function(qt_evaluate_config_expression resultVar)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
|
function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
|
||||||
# Check if either FEATURE_ or INPUT_ are provided by user. INPUT_ also might be set
|
# Enable FEATURE_ variable if INPUT_ is true-like. FEATURE_ value has higher priority.
|
||||||
# when cmake is run by "configure" script.
|
string(TOUPPER "${INPUT_${feature}}" input_value)
|
||||||
if(DEFINED "FEATURE_${feature}")
|
set(booly_values ON YES TRUE Y 1)
|
||||||
set(feature_var "FEATURE_${feature}")
|
if ((NOT DEFINED "FEATURE_${feature}") AND (input_value IN_LIST booly_values))
|
||||||
elseif(DEFINED "INPUT_${feature}" AND NOT "${INPUT_${feature}}" STREQUAL "undefined")
|
set(FEATURE_${feature} ON)
|
||||||
set(feature_var "INPUT_${feature}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT "${feature_var}" STREQUAL "")
|
if (DEFINED "FEATURE_${feature}")
|
||||||
# Must set up the cache
|
# Must set up the cache
|
||||||
if (NOT (emit_if))
|
if (NOT (emit_if))
|
||||||
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} that was not emitted was found in the CMakeCache.")
|
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} that was not emitted was found in the CMakeCache.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Revisit value:
|
# Revisit value:
|
||||||
set(cache "${${feature_var}}")
|
set(cache "${FEATURE_${feature}}")
|
||||||
set(booly_values OFF NO FALSE N ON YES TRUE Y)
|
set(bool_values OFF NO FALSE N ON YES TRUE Y)
|
||||||
if ((cache IN_LIST booly_values) OR (cache GREATER_EQUAL 0))
|
if ((cache IN_LIST bool_values) OR (cache GREATER_EQUAL 0))
|
||||||
set(result "${cache}")
|
set(result "${cache}")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} has invalid value \"${cache}\"!")
|
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} has invalid value \"${cache}\"!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user