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 <frantisek.hrbata@espressif.com>
  • Loading branch information
fhrbata committed Jun 8, 2023
1 parent 96c4ec8 commit 30735b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tools/cmake/utilities.cmake
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 30735b3

Please sign in to comment.