CMake: Use while instead of foreach in qt_evaluate_config_expression
By using a while loop instead of a foreach(RANGE), we can simplify the code and remove the skipNext variable. Also, we need to access the last used iteration index in a future commit. This is not possible with a foreach loop without saving the index in another variable. Change-Id: I39306a0105fb31a6a8f39e9d4c47ee3424599a2b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
This commit is contained in:
parent
f5fc45bcb4
commit
49ff83fcef
@ -84,17 +84,13 @@ endfunction()
|
||||
function(qt_evaluate_config_expression resultVar)
|
||||
set(result "")
|
||||
set(nestingLevel 0)
|
||||
set(skipNext OFF)
|
||||
set(expression "${ARGN}")
|
||||
list(LENGTH expression length)
|
||||
|
||||
set(memberIdx -1)
|
||||
math(EXPR length "${length}-1")
|
||||
foreach(memberIdx RANGE ${length})
|
||||
if(${skipNext})
|
||||
set(skipNext OFF)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
while(memberIdx LESS ${length})
|
||||
math(EXPR memberIdx "${memberIdx} + 1")
|
||||
list(GET expression ${memberIdx} member)
|
||||
|
||||
if("${member}" STREQUAL "(")
|
||||
@ -140,7 +136,7 @@ function(qt_evaluate_config_expression resultVar)
|
||||
set(lhs "${${lhs}}")
|
||||
|
||||
math(EXPR rhsIndex "${memberIdx}+1")
|
||||
set(skipNext ON)
|
||||
set(memberIdx ${rhsIndex})
|
||||
|
||||
list(GET expression ${rhsIndex} rhs)
|
||||
# We can't pass through an empty string with double quotes through various
|
||||
@ -160,7 +156,7 @@ function(qt_evaluate_config_expression resultVar)
|
||||
|
||||
list(APPEND result ${member})
|
||||
endif()
|
||||
endforeach()
|
||||
endwhile()
|
||||
# The 'TARGET Gui' case is handled by qt_evaluate_to_boolean, by passing those tokens verbatim
|
||||
# to if().
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user