string(REPLACE " " ";" SCRIPTS ${SCRIPTS})
set(CPP_SOURCE "")
list(LENGTH SCRIPTS NUM_SCRIPTS)
set(HEADER_SOURCE "#ifndef SCRIPT_SOURCES_H\n#define SCRIPT_SOURCES_H\n\n#define SCRIPT_NUM ${NUM_SCRIPTS}\n")
set(I 0)
FOREACH(N ${SCRIPTS})
	file(READ "${N}" SCRIPT_SOURCE)
	string(REPLACE "\\" "\\\\" SCRIPT_SOURCE ${SCRIPT_SOURCE})
	string(REPLACE "\"" "\\\"" SCRIPT_SOURCE ${SCRIPT_SOURCE})
	string(REPLACE "\n" "\\n" SCRIPT_SOURCE ${SCRIPT_SOURCE})
	string(REPLACE "\t" "\\t" SCRIPT_SOURCE ${SCRIPT_SOURCE})
	get_filename_component(SCRIPT_NAME "${N}" NAME)
	string(REPLACE "." "_" C_NAME ${SCRIPT_NAME})
	string(TOUPPER ${C_NAME} C_NAME)
	set(HEADER_SOURCE "${HEADER_SOURCE}#define SCRIPT_${C_NAME} ${I}\n")
	set(CPP_SOURCE "${CPP_SOURCE}\t\"${SCRIPT_SOURCE}\",\n")
	set(SECOND_ARRAY "${SECOND_ARRAY}\t\"${SCRIPT_NAME}\",\n")
	math(EXPR I "${I}+1")
ENDFOREACH(N)
set(HEADER_SOURCE "${HEADER_SOURCE}extern const char * SCRIPT_ARRAY[${NUM_SCRIPTS}];\nextern const char *SCRIPT_NAME_ARRAY[${NUM_SCRIPTS}];\n\n#endif")
set(SECOND_ARRAY "const char * SCRIPT_NAME_ARRAY[${NUM_SCRIPTS}] = {\n${SECOND_ARRAY}};")
set(CPP_SOURCE "const char * SCRIPT_ARRAY[${NUM_SCRIPTS}] = {\n${CPP_SOURCE}};\n\n${SECOND_ARRAY}")
file(WRITE "${SCRIPT_C_STRING_HEADER_FILE}" "${HEADER_SOURCE}")
file(WRITE "${SCRIPT_C_STRING_CPP_FILE}" "${CPP_SOURCE}")
