CMake: Relax constraint on not having feature values change

Previously if qtbase was built with feature A set to ON, then building
qtsvg, then rebuilding qtbase with feature A set to OFF, trying to
build qtsvg would fail with an error message at configure time saying
that the feature value has changed.

This check was added quite early in the Qt CMake port, presumably to
catch accidental reconfigures that might cause long rebuilds.

This has dubious benefit though. We constantly had people telling us
they get the error without knowing what to do. The usual advice was to
remove CMakeCache.txt and reconfigure.

Instead of forcing people to suffer this dance, relax the constraint
by issuing a warning instead of an error, and make it more clear why
a rebuild might happen (a changed feature value might change
the generated module C++ header file which in turn might be included
by various project sources).

Amends 20633d97ab

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-95834
Change-Id: I992bd61024958869f3b995471b4c7ff75e3a33a0
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
bb10
Alexandru Croitor 2022-08-02 18:39:07 +02:00
parent 97fa1f24b9
commit 15117f84bb
1 changed files with 9 additions and 1 deletions

View File

@ -1256,7 +1256,15 @@ function(qt_make_features_available target)
endif()
foreach(feature IN ITEMS ${features})
if (DEFINED "QT_FEATURE_${feature}" AND NOT "${QT_FEATURE_${feature}}" STREQUAL "${value}")
message(FATAL_ERROR "Feature ${feature} is already defined to be \"${QT_FEATURE_${feature}}\" and should now be set to \"${value}\" when importing features from ${target}.")
message(WARNING
"This project was initially configured with the Qt feature \"${feature}\" "
"set to \"${QT_FEATURE_${feature}}\". While loading the "
"\"${target}\" package, the value of the feature "
"has changed to \"${value}\". That might cause a project rebuild due to "
"updated C++ headers. \n"
"In case of build issues, consider removing the CMakeCache.txt file and "
"reconfiguring the project."
)
endif()
set(QT_FEATURE_${feature} "${value}" CACHE INTERNAL "Qt feature: ${feature} (from target ${target})")
endforeach()