summaryrefslogtreecommitdiffstats
path: root/cmake/QtFeature.cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2020-12-11 16:11:35 +0100
committerAlexey Edelev <alexey.edelev@qt.io>2020-12-17 13:03:37 +0100
commit61943aefd68b7d88c5eb395c4e44d08a94a70ad0 (patch)
tree96afbecf1600a9763acd894d86f6c87898067e73 /cmake/QtFeature.cmake
parenta46a723dbab83c777e45f40a6bd685a07d60ca4e (diff)
CMake: Add detection of FEATURE_foo change by user
Unset all QT_FEATURE_foo values for every build. If any of FEATURE_foo is different of QT_FEATURE_foo, mark whole Qt build as dirty. Reset FEATURE_foo for dirty builds to the calculated value if it doesn't meet its condition. Set Qt module as NOT FOUND if its target was not created during configuration. Main issue with this approach are generated files, that became trash once the related features are disabled. This especially affects features that enable/disable Qt modules. FooConfig.cmake files are created and generate lots of warnings if feature was disabled. We may introduce a module cleanup procedure at some point. Fixes: QTBUG-85962 Pick-to: 6.0 Change-Id: Id71c1edb4027b24c6793063e40cc9d612c24ebce Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtFeature.cmake')
-rw-r--r--cmake/QtFeature.cmake33
1 files changed, 20 insertions, 13 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index be749eedaf..72b4001d57 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -227,7 +227,7 @@ function(_qt_internal_dump_expression_values expression_dump expression)
set(${expression_dump} "${${expression_dump}}" PARENT_SCOPE)
endfunction()
-function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
+function(qt_feature_set_cache_value resultVar feature emit_if condition calculated label)
if (DEFINED "FEATURE_${feature}")
# Must set up the cache
if (NOT (emit_if))
@@ -236,14 +236,25 @@ function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
# Revisit value:
set(cache "${FEATURE_${feature}}")
+
+ # If the build is marked as dirty and the cache value doesn't meet the new condition,
+ # reset it to the calculated one.
+ get_property(dirty_build GLOBAL PROPERTY _qt_dirty_build)
+ if(NOT condition AND cache AND dirty_build)
+ set(cache "${calculated}")
+ message(WARNING "Reset FEATURE_${feature} value to ${calculated}, because it doesn't \
+meet its condition after reconfiguration.")
+ endif()
+
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}\"!")
endif()
+
# Fix-up user-provided values
- set("FEATURE_${feature}" "${cache}" CACHE BOOL "${label}")
+ set("FEATURE_${feature}" "${cache}" CACHE BOOL "${label}" FORCE)
else()
# Initial setup:
if (emit_if)
@@ -271,11 +282,14 @@ macro(qt_feature_set_value feature cache condition label conditionExpression)
message(FATAL_ERROR "Feature ${feature} is already defined when evaluating configure.cmake features for ${target}.")
endif()
set(QT_FEATURE_${feature} "${result}" CACHE INTERNAL "Qt feature: ${feature}")
+
+ # Add feature to build feature collection
+ list(APPEND QT_KNOWN_FEATURES "${feature}")
+ set(QT_KNOWN_FEATURES "${QT_KNOWN_FEATURES}" CACHE INTERNAL "" FORCE)
endmacro()
function(qt_evaluate_feature feature)
- # If the feature was set explicitly by the user to be on or off, in the cache, then
- # there's nothing for us to do.
+ # If the feature was already evaluated as dependency nothing to do here.
if(DEFINED "QT_FEATURE_${feature}")
return()
endif()
@@ -289,10 +303,6 @@ function(qt_evaluate_feature feature)
"PRIVATE;PUBLIC"
"LABEL;PURPOSE;SECTION;" "AUTODETECT;CONDITION;ENABLE;DISABLE;EMIT_IF" ${_QT_FEATURE_DEFINITION_${feature}})
- if(DEFINED QT_FEATURE_${feature})
- return()
- endif()
-
if("${arg_ENABLE}" STREQUAL "")
set(arg_ENABLE OFF)
endif()
@@ -329,10 +339,6 @@ function(qt_evaluate_feature feature)
qt_evaluate_config_expression(emit_if ${arg_EMIT_IF})
endif()
- if (NOT (condition) AND (calculated))
- 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")
@@ -344,7 +350,8 @@ function(qt_evaluate_feature feature)
endif()
endif()
- qt_feature_set_cache_value(cache "${feature}" "${emit_if}" "${result}" "${arg_LABEL}")
+ qt_feature_set_cache_value(cache "${feature}" "${emit_if}" "${condition}" "${result}"
+ "${arg_LABEL}")
qt_feature_set_value("${feature}" "${cache}" "${condition}" "${arg_LABEL}"
"${arg_CONDITION}")