CMake: Fix toggling of FEATURE_developer_build and some other options

Previously if Qt was configured with -developer-build, configure
would pass to CMake -DINPUT_developer_build=ON, which will ensure that
both FEATURE_developer_build and QT_FEATURE_developer_build are set to
ON.
Then if somebody tries to toggle FEATURE_developer_build to OFF in
the CMakeCache.txt and rerun cmake, the feature will bounce back to ON,
due to the code in QtSetup.cmake that doesn't take into account if
FEATURE_developer_build is already defined, and thus reset it based
on the value that is cached in INPUT_developer_build.

Change the checks for INPUT_developer_build and INPUT_no_prefix,
to take into account the defined-ness of their
FEATURE_ counterparts.
If they are defined, ignore the INPUT_ values.

This allows toggling the FEATURE_ variables and also aligns with
the INPUT_ handling behavior that we have in qt_evaluate_feature which
ignores INPUT_ values once the FEATURE_ is defined.

While this aligns the behavior with other features, there is still a
problem.

If you first configure without -developer-build,
and FEATURE_developer_build is set OFF, and then reconfigure with
-developer-build, because FEATURE_developer_build is already defined,
the INPUT_developer_build=ON is ignored.
This is a problem for other features as well and will be handled in a
follow up change.

Pick-to: 6.6
Task-number: QTBUG-112957
Change-Id: I4f31157b0e7963e4d43e28062a585e939ceea0c1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2023-08-24 18:52:55 +02:00
parent 65e04162d1
commit 17efffe1ad

View File

@ -15,16 +15,28 @@ if(NOT QT_INTERNAL_IS_STANDALONE_TEST)
endif()
# Pre-calculate the developer_build feature if it's set by the user via INPUT_developer_build
if(NOT FEATURE_developer_build AND INPUT_developer_build
AND NOT "${INPUT_developer_build}" STREQUAL "undefined")
set(FEATURE_developer_build ON)
if(NOT DEFINED FEATURE_developer_build
AND DEFINED INPUT_developer_build
AND NOT "${INPUT_developer_build}" STREQUAL "undefined"
AND NOT "${INPUT_developer_build}" STREQUAL "")
if(INPUT_developer_build)
set(FEATURE_developer_build ON)
else()
set(FEATURE_developer_build OFF)
endif()
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 FEATURE_no_prefix AND INPUT_no_prefix
AND NOT "${INPUT_no_prefix}" STREQUAL "undefined")
set(FEATURE_no_prefix ON)
if(NOT DEFINED FEATURE_no_prefix
AND DEFINED INPUT_no_prefix
AND NOT "${INPUT_no_prefix}" STREQUAL "undefined"
AND NOT "${INPUT_no_prefix}" STREQUAL "")
if(INPUT_no_prefix)
set(FEATURE_no_prefix ON)
else()
set(FEATURE_no_prefix OFF)
endif()
endif()
set(_default_build_type "Release")