From 30735b33efabd6cf038bcb258b674cf828ad5ecf Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Fri, 14 Apr 2023 14:52:21 +0200 Subject: [PATCH] tools: fix make_json_list to return empty json list for empty cmake list Currently make_json_list() returns '[ "" ]' for empty cmake list. Fix this so empty json list is returned instead. Signed-off-by: Frantisek Hrbata --- tools/cmake/utilities.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/cmake/utilities.cmake b/tools/cmake/utilities.cmake index 68ce8e16e8..3d47a9351e 100644 --- a/tools/cmake/utilities.cmake +++ b/tools/cmake/utilities.cmake @@ -178,7 +178,12 @@ endfunction() # Convert a CMake list to a JSON list and store it in a variable function(make_json_list list variable) - string(REPLACE ";" "\", \"" result "[ \"${list}\" ]") + list(LENGTH list length) + if(${length}) + string(REPLACE ";" "\", \"" result "[ \"${list}\" ]") + else() + set(result "[]") + endif() set("${variable}" "${result}" PARENT_SCOPE) endfunction()