mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-27 03:21:15 +00:00
25 lines
850 B
CMake
25 lines
850 B
CMake
macro(json_get_with_default KEY_STR JSON_STR DEFAULT)
|
|
# message(STATUS "Getting ${ARGN} for ${KEY_STR}")
|
|
string(JSON ${KEY_STR} ERROR_VARIABLE JSON_ERROR GET ${JSON_STR} ${ARGN})
|
|
if(NOT ${JSON_ERROR} STREQUAL "NOTFOUND")
|
|
set(${KEY_STR} ${DEFAULT})
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(json_get KEY_STR JSON_STR)
|
|
# message(STATUS "Getting ${ARGN} for ${KEY_STR}")
|
|
string(JSON ${KEY_STR} ERROR_VARIABLE JSON_ERROR GET ${JSON_STR} ${ARGN})
|
|
if(NOT ${JSON_ERROR} STREQUAL "NOTFOUND")
|
|
unset(${KEY_STR})
|
|
endif()
|
|
endmacro()
|
|
|
|
macro(parent_list ACTION LIST_STR)
|
|
set(ARGS ${ARGN})
|
|
string(REPLACE ";" " " ARGS ${ARGS})
|
|
set(LOCAL_LIST ${${LIST_STR}})
|
|
list(${ACTION} LOCAL_LIST ${ARGS})
|
|
# set in current scope too
|
|
set(${LIST_STR} ${LOCAL_LIST})
|
|
set(${LIST_STR} ${LOCAL_LIST} PARENT_SCOPE)
|
|
endmacro() |