summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <[email protected]>2023-09-12 16:57:56 +0200
committerAlexandru Croitor <[email protected]>2023-09-13 20:09:19 +0200
commitd1a17d96550362b28f77a6bbff9dd15b15d40559 (patch)
tree9bb38c100370f3da153841c3eb057a5d31ca2012
parent47a42b9c6a523478dc30732a17bc0ac1e02d301d (diff)
CMake: Fix reconfiguration when -no-opengl is specified
In a previous change, we ensured that all INPUT_foo cache variables are unset at the end of configuration, so they don't influence feature re-evaluation in case if a command line flag like -no-gui is not specified upon second reconfiguration and a FEATURE_foo is manually toggled in the CMakeCache.txt, effectively getting rid of stale INPUT_foo values. Unfortunately that causes an issue when configuring with -no-opengl and then trying to reconfigure with 'cmake .' Specifically various feature options like ENABLE / DISABLE use INPUT_foo variables in their expressions. qt_configure_add_report_entry CONDITIONs also use them. These expect the INPUT_foo variables to be persisted, and if they are removed, the expressions might be re-evaluated to a different value, and cause re-configuration to fail or unexpectedly toggle features. To support both cases described above, instead of removing all INPUT variables when configuration ends, only unset those INPUT variables whose corresponding FEATURE_foo variable has been manually toggled in CMakeCache.txt or via an IDE. Toggling a FEATURE_foo manually is intentional, which means the INPUT_foo value should be discarded. Whereas pre-existing INPUT_bar variables will persist, thus not breaking cases like the -no-opengl report CONDITION. Amends 2799391703e44a34b6557e234462e425a61785f2 Pick-to: 6.6 Fixes: QTBUG-116973 Task-number: QTBUG-112957 Change-Id: I5851255bfa41a9a1d116630a5d9f7b9a74aa93ed Reviewed-by: Alexey Edelev <[email protected]>
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake8
-rw-r--r--cmake/QtFeature.cmake24
2 files changed, 17 insertions, 15 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index dda9f8f0939..c34b4e83991 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -106,6 +106,8 @@ endif()
include(QtPlatformSupport)
# Set FEATURE_${feature} if INPUT_${feature} is set in certain circumstances.
+# Set FEATURE_${feature}_computed_from_input to TRUE or FALSE depending on whether the
+# INPUT_${feature} value has overridden the FEATURE_${feature} variable.
#
# Needs to be in QtBuildInternalsConfig.cmake instead of QtFeature.cmake because it's used in
# qt_build_internals_disable_pkg_config_if_needed.
@@ -126,6 +128,9 @@ function(qt_internal_compute_feature_value_from_possible_input feature)
endif()
set(FEATURE_${feature} "${FEATURE_${feature}}" PARENT_SCOPE)
+ set(FEATURE_${feature}_computed_from_input TRUE PARENT_SCOPE)
+ else()
+ set(FEATURE_${feature}_computed_from_input FALSE PARENT_SCOPE)
endif()
endfunction()
@@ -635,9 +640,6 @@ function(qt_internal_qt_configure_end)
# reconfigurations that are done by calling cmake directly don't trigger configure specific
# logic.
unset(QT_INTERNAL_CALLED_FROM_CONFIGURE CACHE)
-
- # Clean up stale feature input values.
- qt_internal_clean_feature_inputs()
endfunction()
macro(qt_build_repo)
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake
index 207abd58c97..9620c1df581 100644
--- a/cmake/QtFeature.cmake
+++ b/cmake/QtFeature.cmake
@@ -883,6 +883,18 @@ function(qt_internal_detect_dirty_features)
"to ${FEATURE_${feature}}")
set(dirty_build TRUE)
set_property(GLOBAL APPEND PROPERTY _qt_dirty_features "${feature}")
+
+ # If the user changed the value of the feature directly (e.g by editing
+ # CMakeCache.txt), and not via its associated INPUT variable, unset the INPUT cache
+ # variable before it is used in feature evaluation, to ensure a stale value doesn't
+ # influence other feature values, especially when QT_INTERNAL_CALLED_FROM_CONFIGURE
+ # is TRUE and the INPUT_foo variable is not passed.
+ # e.g. first configure -no-gui, then manually toggle FEATURE_gui to ON in
+ # CMakeCache.txt, then reconfigure (with the configure script) without -no-gui.
+ # Without this unset(), we'd have switched FEATURE_gui to OFF again.
+ if(NOT FEATURE_${feature}_computed_from_input)
+ unset("INPUT_${feature}" CACHE)
+ endif()
endif()
unset("QT_FEATURE_${feature}" CACHE)
endforeach()
@@ -899,18 +911,6 @@ function(qt_internal_detect_dirty_features)
endif()
endfunction()
-function(qt_internal_clean_feature_inputs)
- foreach(feature IN LISTS QT_KNOWN_FEATURES)
- # Unset the INPUT_foo cache variables after they were used in feature evaluation, to
- # ensure stale values don't influence features upon reconfiguration when
- # QT_INTERNAL_CALLED_FROM_CONFIGURE is TRUE and the INPUT_foo variable is not passed.
- # e.g. first configure -no-gui, then manually toggle FEATURE_gui to ON in
- # CMakeCache.txt, then reconfigure (with the configure script) without -no-gui.
- # Without this unset(), we'd have switched FEATURE_gui to OFF again.
- unset(INPUT_${feature} CACHE)
- endforeach()
-endfunction()
-
function(qt_config_compile_test name)
if(DEFINED "TEST_${name}")
return()