json.cmake 378 B

12345678
  1. macro(read_json filename outvar)
  2. file(READ ${filename} contents)
  3. # string(JSON *) will fail if JSON file contains any forward-slash paths
  4. string(REGEX REPLACE "[\\]([a-zA-Z0-9 ])" "/\\1" contents ${contents})
  5. # string(JSON *) will fail if JSON file contains any escaped quotes \"
  6. string(REPLACE "\\\"" "'" contents ${contents})
  7. set(${outvar} ${contents})
  8. endmacro()