Build: Fix CONDITION with multiple parts

for add_qtc_test and qtc_add_resources.
The condition needs to be wrapped in () because otherwise conditions
that contain AND or OR themselves break.

Change-Id: Iff64ad15c5f5b6e5a9db5a97c975bd8854c59c02
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2023-03-23 08:49:34 +01:00
parent 7a4ef9c1f7
commit d99128e5e6

View File

@@ -836,7 +836,12 @@ function(add_qtc_test name)
endif() endif()
set(${_build_test_var} "${_build_test_default}" CACHE BOOL "Build test ${name}.") set(${_build_test_var} "${_build_test_default}" CACHE BOOL "Build test ${name}.")
if (NOT ${_build_test_var} OR NOT ${_arg_CONDITION}) if ((${_arg_CONDITION}) AND ${_build_test_var})
set(_test_enabled ON)
else()
set(_test_enabled OFF)
endif()
if (NOT _test_enabled)
return() return()
endif() endif()
@@ -864,7 +869,6 @@ function(add_qtc_test name)
DEFINES ${_arg_DEFINES} ${TEST_DEFINES} ${default_defines_copy} DEFINES ${_arg_DEFINES} ${TEST_DEFINES} ${default_defines_copy}
EXPLICIT_MOC ${_arg_EXPLICIT_MOC} EXPLICIT_MOC ${_arg_EXPLICIT_MOC}
SKIP_AUTOMOC ${_arg_SKIP_AUTOMOC} SKIP_AUTOMOC ${_arg_SKIP_AUTOMOC}
CONDITION ${_arg_CONDITION}
) )
set_target_properties(${name} PROPERTIES set_target_properties(${name} PROPERTIES
@@ -984,7 +988,10 @@ function(qtc_add_resources target resourceName)
message(FATAL_ERROR "qtc_add_resources had unparsed arguments!") message(FATAL_ERROR "qtc_add_resources had unparsed arguments!")
endif() endif()
if (DEFINED _arg_CONDITION AND NOT _arg_CONDITION) if (NOT _arg_CONDITION)
set(_arg_CONDITION ON)
endif()
if (NOT (${_arg_CONDITION}))
return() return()
endif() endif()