From aa6ad154243b514cd55b10af64b72f4fa3d1cd02 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 4 Nov 2020 16:00:50 +0100 Subject: 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 --- cmake/QtFeature.cmake | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'cmake') diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index acf120dfcf..ed51bc8f68 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -171,24 +171,23 @@ function(qt_evaluate_config_expression resultVar) endfunction() 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 - # 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}") + # 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(NOT "${feature_var}" STREQUAL "") + if (DEFINED "FEATURE_${feature}") # 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_var}}") - set(booly_values OFF NO FALSE N ON YES TRUE Y) - if ((cache IN_LIST booly_values) OR (cache GREATER_EQUAL 0)) + set(cache "${FEATURE_${feature}}") + set(bool_values OFF NO FALSE N ON YES TRUE Y) + if ((cache IN_LIST bool_values) OR (cache GREATER_EQUAL 0)) set(result "${cache}") else() message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} has invalid value \"${cache}\"!") -- cgit v1.2.3