From 339abc57529cbfed0edcd511a306e6a1d1f48d67 Mon Sep 17 00:00:00 2001 From: Henrik Gaßmann Date: Wed, 2 Apr 2025 18:29:42 +0200 Subject: refactor: fix a few nits in the join function The `join_pkg_config_requires` function would misbehave in a few edge cases. Though these edge cases aren't triggered by our current usage. --- c/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index ba3b855..d723983 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -334,16 +334,17 @@ endfunction() # # TODO: Replace function with list(JOIN) when updating to CMake 3.12 function(join_pkg_config_requires requires) - list(LENGTH ${requires} len) + set(_requires "${${requires}}") # avoid shadowing issues, e.g. "${requires}"=len + list(LENGTH "${requires}" len) set(idx 1) - foreach(req ${${requires}}) - string(APPEND acc ${req}) + foreach(req IN LISTS _requires) + string(APPEND acc "${req}") if(idx LESS len) string(APPEND acc ", ") endif() math(EXPR idx "${idx} + 1") endforeach() - set(${requires} ${acc} PARENT_SCOPE) + set("${requires}" "${acc}" PARENT_SCOPE) endfunction() # calculate pkg-config requirements -- cgit v1.2.3