summaryrefslogtreecommitdiffstats
path: root/cmake/QtFeature.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-07-08 17:40:04 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-07-09 12:44:35 +0200
commit451733bd578a04b71147fc2d56bfcb150e3dd981 (patch)
treec9834bca1492aa107f100ca9ca84efa6a27e3886 /cmake/QtFeature.cmake
parentcde126ef2659b21b12dd28b73e3c7fca0bd3bf2f (diff)
CMake: Fix reconfiguration error when features have EMIT_IF conditions
Previously, if a feature was marked as not to be emitted and there was no user provided value for that feature, the build system would still save the user provided value in FEATURE_foo with a value of ON (if the conditions were met). After a reconfiguration, the build system would hit the code path that checks if the user provided a value for the non-emitted feature, and would then warn about it and reset the feature value to OFF. This would cause errors when reconfiguring a user project, complaining that a feature value has changed. Make sure to not save the user provided value for a non-emitted feature and to always set its internal feature value to OFF. Amends c4f5762b20dc20bab3cc62e9166d0e5b36e21cc6 Pick-to: 6.2 Fixes: QTBUG-94921 Change-Id: I257c7fd795c8a6aeba3348cb72522e4f0b006dc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtFeature.cmake')
-rw-r--r--cmake/QtFeature.cmake17
1 files changed, 13 insertions, 4 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index f5712cbc44..e069dad23d 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -374,18 +374,27 @@ function(qt_evaluate_feature feature)
endif()
endif()
+ # Warn about a feature which is not emitted, but the user explicitly provided a value for it.
if(NOT emit_if AND DEFINED FEATURE_${feature})
set(msg "")
string(APPEND msg
"Feature ${feature} is insignificant in this configuration, "
"ignoring related command line option(s).")
qt_configure_add_report_entry(TYPE WARNING MESSAGE "${msg}")
- set(computed OFF)
- set(FEATURE_${feature} OFF)
+
+ # Remove the cache entry so that the warning is not persisted and shown on every
+ # reconfiguration.
+ unset(FEATURE_${feature} CACHE)
endif()
- qt_feature_check_and_save_user_provided_value(
- saved_user_value "${feature}" "${condition}" "${computed}" "${arg_LABEL}")
+ # Only save the user provided value if the feature was emitted.
+ if(emit_if)
+ qt_feature_check_and_save_user_provided_value(
+ saved_user_value "${feature}" "${condition}" "${computed}" "${arg_LABEL}")
+ else()
+ # Make sure the feature internal value is OFF if not emitted.
+ set(saved_user_value OFF)
+ endif()
qt_feature_check_and_save_internal_value(
"${feature}" "${saved_user_value}" "${condition}" "${arg_LABEL}" "${arg_CONDITION}")