Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.5
-
None
-
-
ad227368c (dev), 5280f307a (6.8)
Description
Consider a Linux machine with libb2-dev not installed.
Trying to configure Qt with the -system-libb2 flag should print an error message.
Instead, Qt is silently configured to use the bundled libb2.
Configuring with -feature-system-libb2, however, yields the expected error:
CMake Error at cmake/QtBuildInformation.cmake:534 (message): Feature "system_libb2": Forcing to "ON" breaks its condition: Libb2_FOUND Condition values dump: Libb2_FOUND = "" Call Stack (most recent call first): cmake/QtFeature.cmake:369 (qt_configure_add_report_error) cmake/QtFeature.cmake:502 (qt_feature_check_and_save_internal_value) cmake/QtFeature.cmake:771 (qt_evaluate_feature) cmake/QtFeature.cmake:740 (qt_feature_module_end) src/CMakeLists.txt:8 (qt_feature_evaluate_features)
The system-libb2 feature is defined like this:
qt_feature("system-libb2" PRIVATE LABEL "Using system libb2" CONDITION Libb2_FOUND ENABLE INPUT_libb2 STREQUAL 'system' DISABLE INPUT_libb2 STREQUAL 'no' OR INPUT_libb2 STREQUAL 'qt' )
The ENABLE/DISABLE expressions react on the configure switches -system-libb2, -qt-libb2 and -no-libb2.
The root of the missing error message lies in QtFeature.cmake's qt_evaluate_feature function:
if(${disable_result}) set(computed OFF) elseif((${enable_result}) OR (${auto_detect})) set(computed ${condition}) else() # feature not auto-detected and not explicitly enabled set(computed OFF) endif()
Due to the -system-libb2 configure switch, enable_result is trueish.
Then, computed is set to the value of condition.
Since the feature value is not user-provided via FEATURE_system_libb2, the computed value is used for the feature.
Later, in qt_feature_check_and_save_internal_value, we compare the feature value against the condition's value, and if they differ, we yield the error.
In this situation, however, computed is exactly condition, and there's no error.
Conclusion of all this: if a feature is enabled via its ENABLE expression, it should be considered as enabled by the user. In this case, there should be an error message.
Another data point that supports this claim:
ENABLE / DISABLE expressions contain INPUT_... values and thus react on user input.
Attachments
For Gerrit Dashboard: QTBUG-126144 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
566741,4 | CMake: Yield error if a feature is ENABLEd and CONDITION is false | dev | qt/qtbase | Status: MERGED | +2 | 0 |
568083,2 | CMake: Yield error if a feature is ENABLEd and CONDITION is false | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |