Files
CMake/Tests/RunCMake/Instrumentation/json.cmake
Martin Duffy 097d4fd1b5 instrumentation: Collect and record project build system metrics
Add a feature for collecting build instrumentation for CMake projects.

Issue: #26099
2025-01-15 09:16:50 -05:00

9 lines
378 B
CMake

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