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>
(cherry picked from commit 17efffe1ad6b85f45f418d5d08b5e85a456b12e3)
This commit is contained in:
Alexandru Croitor 2023-08-24 18:52:55 +02:00
parent b52817db13
commit d416da582b

View File

@ -9,16 +9,28 @@ set(QT_BUILDING_QT TRUE CACHE BOOL
"When this is present and set to true, it signals that we are building Qt from source.") "When this is present and set to true, it signals that we are building Qt from source.")
# Pre-calculate the developer_build feature if it's set by the user via INPUT_developer_build # 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 if(NOT DEFINED FEATURE_developer_build
AND NOT "${INPUT_developer_build}" STREQUAL "undefined") AND DEFINED INPUT_developer_build
set(FEATURE_developer_build ON) 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() endif()
# Pre-calculate the no_prefix feature if it's set by configure via INPUT_no_prefix. # 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. # This needs to be done before qtbase/configure.cmake is processed.
if(NOT FEATURE_no_prefix AND INPUT_no_prefix if(NOT DEFINED FEATURE_no_prefix
AND NOT "${INPUT_no_prefix}" STREQUAL "undefined") AND DEFINED INPUT_no_prefix
set(FEATURE_no_prefix ON) 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() endif()
set(_default_build_type "Release") set(_default_build_type "Release")