From 61943aefd68b7d88c5eb395c4e44d08a94a70ad0 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 11 Dec 2020 16:11:35 +0100 Subject: 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 --- cmake/QtSetup.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cmake/QtSetup.cmake') diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index ec8be5e269..13daf40381 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -222,3 +222,27 @@ if(QT_USE_CCACHE) message(WARNING "Ccache use was requested, but the program was not found.") endif() endif() + +# We need to clean up QT_FEATURE_*, but only once per configuration cycle +get_property(qt_feature_clean GLOBAL PROPERTY _qt_feature_clean) +if(NOT qt_feature_clean) + message(STATUS "Check for feature set changes") + set_property(GLOBAL PROPERTY _qt_feature_clean TRUE) + foreach(feature ${QT_KNOWN_FEATURES}) + if(DEFINED "FEATURE_${feature}" AND + NOT "${QT_FEATURE_${feature}}" STREQUAL "${FEATURE_${feature}}") + message(" '${feature}' is changed from ${QT_FEATURE_${feature}} \ +to ${FEATURE_${feature}}") + set(dirty_build TRUE) + endif() + unset("QT_FEATURE_${feature}" CACHE) + endforeach() + + set(QT_KNOWN_FEATURES "" CACHE INTERNAL "" FORCE) + + if(dirty_build) + set_property(GLOBAL PROPERTY _qt_dirty_build TRUE) + message(WARNING "Re-configuring in existing build folder. \ +Some features will be re-evaluated automatically.") + endif() +endif() -- cgit v1.2.3