cmake_minimum_required (VERSION 3.2)

# Symbol to generate
set(filename ${SYMBOL})

# Create header for CPP file
file(WRITE ${OUTPUT_C} "/* Autogenerated by bin2c */\n\n")
file(APPEND ${OUTPUT_C} "#include \"${filename}.h\"\n\n")

# Create header of H file
file(WRITE ${OUTPUT_H} "/* Autogenerated by bin2c */\n\n")
file(APPEND ${OUTPUT_H} "#pragma once\n")
file(APPEND ${OUTPUT_H} "#include <string>\n\n")

# Read hex data from file
file(READ ${INPUT_FILE} filedata HEX)
# Convert hex data for C compatibility
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})
# Append data to c file
file(APPEND ${OUTPUT_C} "const std::string ${filename}{${filedata}};\n\n")
# Append extern definitions to h file
file(APPEND ${OUTPUT_H} "extern const std::string ${filename};\n\n")
