Utils.cmake 850 B

12345678910111213141516171819202122232425
  1. macro(json_get_with_default KEY_STR JSON_STR DEFAULT)
  2. # message(STATUS "Getting ${ARGN} for ${KEY_STR}")
  3. string(JSON ${KEY_STR} ERROR_VARIABLE JSON_ERROR GET ${JSON_STR} ${ARGN})
  4. if(NOT ${JSON_ERROR} STREQUAL "NOTFOUND")
  5. set(${KEY_STR} ${DEFAULT})
  6. endif()
  7. endmacro()
  8. macro(json_get KEY_STR JSON_STR)
  9. # message(STATUS "Getting ${ARGN} for ${KEY_STR}")
  10. string(JSON ${KEY_STR} ERROR_VARIABLE JSON_ERROR GET ${JSON_STR} ${ARGN})
  11. if(NOT ${JSON_ERROR} STREQUAL "NOTFOUND")
  12. unset(${KEY_STR})
  13. endif()
  14. endmacro()
  15. macro(parent_list ACTION LIST_STR)
  16. set(ARGS ${ARGN})
  17. string(REPLACE ";" " " ARGS ${ARGS})
  18. set(LOCAL_LIST ${${LIST_STR}})
  19. list(${ACTION} LOCAL_LIST ${ARGS})
  20. # set in current scope too
  21. set(${LIST_STR} ${LOCAL_LIST})
  22. set(${LIST_STR} ${LOCAL_LIST} PARENT_SCOPE)
  23. endmacro()