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 <alexandru.croitor@qt.io>
(cherry picked from commit b71647d06970b2cc3b63b93c020eca8caf0a519f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Cristian Le 2025-01-21 17:07:16 +01:00 committed by Qt Cherry-pick Bot
parent 7e80af2bc2
commit 9601b5fa5b

View File

@ -353,6 +353,15 @@ function(qt_feature_check_and_save_user_provided_value
set("FEATURE_${feature}" "${result}" CACHE BOOL "${label}") set("FEATURE_${feature}" "${result}" CACHE BOOL "${label}")
endif() 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) set("${resultVar}" "${result}" PARENT_SCOPE)
endfunction() endfunction()