CMake: Rework INPUT_foo vars handling when reconfiguring
To be able to reconfigure Qt with modified feature values using the configure script, and take into account INPUT_foo values, we need to ignore FEATURE_foo values. But we can't always ignore FEATURE_foo values, because users might want to toggle them by editing CMakeCache.txt or using an IDE. What we can do is tell CMake we are configuring via the configure script, in which case we can mostly be sure that any passed INPUT_foo values should have higher priority than pre-cached FEATURE_foo values. We also need to remove all the cached INPUT_foo variables after they have been used for feature computation, so that subsequent reconfigurations where an INPUT_foo is not passed anymore, doesn't cause a feature to accidentally reuse the previous (stale) value. Pass -DQT_INTERNAL_CALLED_FROM_CONFIGURE=TRUE to CMake when configuring via the configure script, and use that as a marker to make INPUT_foo values have a higher priority. This needs to be done centrally in qt_evaluate_feature and also in a few more locations where we check INPUT_ values, like the developer build and pkgconfig features. Because QT_INTERNAL_CALLED_FROM_CONFIGURE would become a cached variable, we want to remove it at the end of the configuration phase, so that future 'cmake .' reconfigurations are not considered to be done via configure. To do that, we unset it right at the end of qt_build_repo_end in a per-repo build, and in the final qt_print_build_instructions call in a top-level build. The latter needs a cleaner fix in follow up commits in qt5.git and qtbase. Pick-to: 6.6 Task-number: QTBUG-112957 Change-Id: I3fd338092041ef09e3f5a4dfbaf61da5deea0514 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
17efffe1ad
commit
2799391703
@ -111,6 +111,12 @@ from the build directory")
|
||||
if(QT_SUPERBUILD)
|
||||
qt_internal_save_previously_visited_packages()
|
||||
endif()
|
||||
|
||||
# TODO: Abuse qt_print_build_instructions being called as the last command in a top-level build.
|
||||
# Instead we should call this explicitly at the end of the top-level project.
|
||||
if(QT_SUPERBUILD)
|
||||
qt_internal_qt_configure_end()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_configure_print_summary_helper summary_reports force_show)
|
||||
|
@ -131,9 +131,10 @@ function(qt_build_internals_disable_pkg_config_if_needed)
|
||||
endif()
|
||||
|
||||
# Features won't have been evaluated yet if this is the first run, have to evaluate this here
|
||||
if ((NOT DEFINED "FEATURE_pkg_config") AND (DEFINED "INPUT_pkg_config")
|
||||
AND (NOT "${INPUT_pkg_config}" STREQUAL "undefined")
|
||||
AND (NOT "${INPUT_pkg_config}" STREQUAL ""))
|
||||
if((NOT DEFINED "FEATURE_pkg_config" OR QT_INTERNAL_CALLED_FROM_CONFIGURE)
|
||||
AND DEFINED INPUT_pkg_config
|
||||
AND NOT "${INPUT_pkg_config}" STREQUAL "undefined"
|
||||
AND NOT "${INPUT_pkg_config}" STREQUAL "")
|
||||
if(INPUT_pkg_config)
|
||||
set(FEATURE_pkg_config ON)
|
||||
else()
|
||||
@ -603,9 +604,27 @@ macro(qt_build_repo_end)
|
||||
set(QT_INTERNAL_FRESH_REQUESTED "FALSE" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
if(NOT QT_SUPERBUILD)
|
||||
qt_internal_qt_configure_end()
|
||||
endif()
|
||||
|
||||
list(POP_BACK CMAKE_MESSAGE_CONTEXT)
|
||||
endmacro()
|
||||
|
||||
# Function called either at the end of per-repo configuration, or at the end of configuration of
|
||||
# a super build.
|
||||
# At the moment it is called before examples are configured in a per-repo build. We might want
|
||||
# to change that at some point if needed.
|
||||
function(qt_internal_qt_configure_end)
|
||||
# If Qt is configued via the configure script, remove the marker variable, so that any future
|
||||
# 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)
|
||||
qt_build_repo_begin(${ARGN})
|
||||
|
||||
|
@ -410,10 +410,15 @@ function(qt_evaluate_feature feature)
|
||||
qt_evaluate_config_expression(emit_if ${arg_EMIT_IF})
|
||||
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")
|
||||
AND (NOT "${INPUT_${feature}}" STREQUAL ""))
|
||||
# If FEATURE_ is not defined try to use the INPUT_ variable to enable/disable feature.
|
||||
# If FEATURE_ is defined and the configure script is being used (so
|
||||
# QT_INTERNAL_CALLED_FROM_CONFIGURE is TRUE), ignore the FEATURE_ variable, and take into
|
||||
# account the INPUT_ variable instead, because a command line argument takes priority over
|
||||
# a pre-cached FEATURE_ variable.
|
||||
if((NOT DEFINED FEATURE_${feature} OR QT_INTERNAL_CALLED_FROM_CONFIGURE)
|
||||
AND DEFINED INPUT_${feature}
|
||||
AND NOT "${INPUT_${feature}}" STREQUAL "undefined"
|
||||
AND NOT "${INPUT_${feature}}" STREQUAL "")
|
||||
if(INPUT_${feature})
|
||||
set(FEATURE_${feature} ON)
|
||||
else()
|
||||
@ -906,6 +911,18 @@ 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()
|
||||
|
@ -179,6 +179,10 @@ else()
|
||||
set(multi_config OFF)
|
||||
endif()
|
||||
|
||||
# Tell the build system we are configuring via the configure script so we can act on that.
|
||||
# The cache variable is unset at the end of configuration.
|
||||
push("-DQT_INTERNAL_CALLED_FROM_CONFIGURE:BOOL=TRUE")
|
||||
|
||||
if(FRESH_REQUESTED)
|
||||
push("-DQT_INTERNAL_FRESH_REQUESTED:BOOL=TRUE")
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
|
||||
|
@ -14,8 +14,10 @@ if(NOT QT_INTERNAL_IS_STANDALONE_TEST)
|
||||
"When this is present and set to true, it signals that we are building Qt from source.")
|
||||
endif()
|
||||
|
||||
# Pre-calculate the developer_build feature if it's set by the user via INPUT_developer_build
|
||||
if(NOT DEFINED FEATURE_developer_build
|
||||
# Pre-calculate the developer_build feature if it's set by the user via the INPUT_developer_build
|
||||
# variable when using the configure script. When not using configure, don't take the INPUT variable
|
||||
# into account, so that users can toggle the feature directly in the cache or via IDE.
|
||||
if((NOT DEFINED FEATURE_developer_build OR QT_INTERNAL_CALLED_FROM_CONFIGURE)
|
||||
AND DEFINED INPUT_developer_build
|
||||
AND NOT "${INPUT_developer_build}" STREQUAL "undefined"
|
||||
AND NOT "${INPUT_developer_build}" STREQUAL "")
|
||||
@ -28,7 +30,7 @@ endif()
|
||||
|
||||
# Pre-calculate the no_prefix feature if it's set by configure via INPUT_no_prefix.
|
||||
# This needs to be done before qtbase/configure.cmake is processed.
|
||||
if(NOT DEFINED FEATURE_no_prefix
|
||||
if((NOT DEFINED FEATURE_no_prefix OR QT_INTERNAL_CALLED_FROM_CONFIGURE)
|
||||
AND DEFINED INPUT_no_prefix
|
||||
AND NOT "${INPUT_no_prefix}" STREQUAL "undefined"
|
||||
AND NOT "${INPUT_no_prefix}" STREQUAL "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user