From 9601b5fa5b1ed390274d02c02bc6530f4ad9b42f Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Tue, 21 Jan 2025 17:07:16 +0100 Subject: [PATCH] Check for misspelled `FEATURE_*` variable The feature names are normalized using `qt_feature_normalize_name`, but a user might read `qt_feature` usage and not realize that they should normalize the name in the `FEATURE_*` variable. This change emits an error if it detects such invalid names. Fixes: QTBUG-132464 Pick-to: 6.8 Change-Id: I33c7ab9f589c92e11e16d376660e8b6152339d12 Reviewed-by: Alexandru Croitor (cherry picked from commit b71647d06970b2cc3b63b93c020eca8caf0a519f) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtFeature.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 453f3d72116..42496f94712 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -353,6 +353,15 @@ function(qt_feature_check_and_save_user_provided_value set("FEATURE_${feature}" "${result}" CACHE BOOL "${label}") endif() + # Check for potential typo + get_property(original_name GLOBAL PROPERTY "QT_FEATURE_ORIGINAL_NAME_${feature}") + if(NOT original_name STREQUAL feature AND DEFINED "FEATURE_${original_name}") + unset("FEATURE_${original_name}" CACHE) + qt_configure_add_report_error( + "FEATURE_${original_name} does not exist. Consider using: FEATURE_${feature}" + ) + endif() + set("${resultVar}" "${result}" PARENT_SCOPE) endfunction()