Skip to content

Commit

Permalink
tools: fix make_json_list to return empty json list for empty cmake list
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
fhrbata committed Jun 8, 2023
1 parent 3f0ccda commit ee505a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/cmake/utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit ee505a9

Please sign in to comment.