diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-09-21 09:15:39 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2023-09-21 21:46:46 +0200 |
commit | 49ff83fcef270c2a4317b5c95524c08a26120074 (patch) | |
tree | 12bee38ba9cffcbabb2312b3aafa5b496412af47 | |
parent | f5fc45bcb47688c869340b2c4a4e021e7ce44329 (diff) |
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>
-rw-r--r-- | cmake/QtFeature.cmake | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 0f2b55b8ce..2c6fa94c25 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -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(). |