minecraft-pi-reborn/cmake/util/embed-resource.cmake

16 lines
381 B
CMake
Raw Normal View History

2022-08-06 00:08:13 +00:00
# Read Hex Data
file(READ "${EMBED_IN}" data HEX)
# Convert Hex Data For C Compatibility
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data "${data}")
# Get C Name
2024-11-15 20:26:33 +00:00
cmake_path(GET EMBED_OUT STEM name)
2022-08-06 00:08:13 +00:00
# Write Data
2024-11-15 20:26:33 +00:00
file(WRITE "${EMBED_OUT}"
"#include <stddef.h>\n"
"const unsigned char ${name}[] = {${data}};\n"
"const size_t ${name}_len = sizeof (${name});\n"
)