Skip to content

Commit 30735b3

Browse files
committed
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 <[email protected]>
1 parent 96c4ec8 commit 30735b3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/cmake/utilities.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ endfunction()
178178

179179
# Convert a CMake list to a JSON list and store it in a variable
180180
function(make_json_list list variable)
181-
string(REPLACE ";" "\", \"" result "[ \"${list}\" ]")
181+
list(LENGTH list length)
182+
if(${length})
183+
string(REPLACE ";" "\", \"" result "[ \"${list}\" ]")
184+
else()
185+
set(result "[]")
186+
endif()
182187
set("${variable}" "${result}" PARENT_SCOPE)
183188
endfunction()
184189

0 commit comments

Comments
 (0)