cmake: Support CMake-typical booly values for -DFEATURE_*

Allow setting feature defines to ON, YES, TRUE, Y, OFF, NO, FALSE, N and
non-negative numbers like it's possible for other defines.

We'll not allow IGNORE and NOTFOUND, because they're a bit strange in
the context of features.

Change-Id: I7f6cd6dff4c68972921b499b28916c9ad789d510
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CMake Build Bot
This commit is contained in:
Joerg Bornemann 2019-09-26 15:39:06 +02:00
parent deeddf2cb1
commit 992fe06b30

View File

@ -163,7 +163,8 @@ function(qt_feature_set_cache_value resultVar feature emit_if calculated label)
# Revisit value:
set(cache "${FEATURE_${feature}}")
if ((cache STREQUAL "ON") OR (cache STREQUAL "OFF"))
set(booly_values OFF NO FALSE N ON YES TRUE Y)
if ((cache IN_LIST booly_values) OR (cache GREATER_EQUAL 0))
set(result "${cache}")
else()
message(FATAL_ERROR "Sanity check failed: FEATURE_${feature} has invalid value \"${cache}\"!")