diff --git a/cmake/QtCMakeHelpers.cmake b/cmake/QtCMakeHelpers.cmake index 261e9cc4574..6c62897d203 100644 --- a/cmake/QtCMakeHelpers.cmake +++ b/cmake/QtCMakeHelpers.cmake @@ -132,11 +132,13 @@ function(qt_remove_args out_var) list(REMOVE_AT result ${find_result}) list(LENGTH result result_len) list(GET result ${find_result} arg_current) - # remove values until we hit another arg + # remove values until we hit another arg or the end of the list while(NOT ${arg_current} IN_LIST arg_ALL_ARGS AND find_result LESS result_len) list(REMOVE_AT result ${find_result}) - list(GET result ${find_result} arg_current) list(LENGTH result result_len) + if (NOT find_result EQUAL result_len) + list(GET result ${find_result} arg_current) + endif() endwhile() endif() endforeach()