Debian Codegraph @

cmake/utils/stringify_shader.cmake

raw
1 # Convert a shader file to a compilable C file
2
3 # INPUT_FILE, OUTPUT_FILE, SHADER_NAME must be set via -D
4
5 file(READ ${INPUT_FILE} CONTENTS)
6
7 string(REPLACE "\\" "\\\\" CONTENTS "${CONTENTS}") # Escape backslashes
8 string(REPLACE "\"" "\\\"" CONTENTS "${CONTENTS}") # Escape double quotes
9 string(REPLACE "\n" "\\n\"\n\"" CONTENTS "${CONTENTS}") # Escape newlines
10
11 set(OUTPUT_CONTENT "const char *fallbackShader_${SHADER_NAME} =\n\"${CONTENTS}\";\n")
12
13 file(WRITE ${OUTPUT_FILE} "${OUTPUT_CONTENT}")