1 FILE (WRITE ${HEADER_FILE} "#ifndef COUNTRY_FLAGS_H\n")
2 FILE (APPEND ${HEADER_FILE} "#define COUNTRY_FLAGS_H\n")
3 FILE (APPEND ${HEADER_FILE} "\n")
4 FILE (APPEND ${HEADER_FILE} "namespace flags {\n")
6 FILE (GLOB FLAGS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.xpm)
8 FOREACH (FLAG ${FLAGS})
9 FILE (APPEND ${HEADER_FILE} "#include \"${FLAG}\"\n")
10 ENDFOREACH (FLAG ${FLAGS})
12 FILE (APPEND ${HEADER_FILE} "\n")
14 FILE (APPEND ${HEADER_FILE} "struct FlagXPMCode\n")
15 FILE (APPEND ${HEADER_FILE} "{\n")
16 FILE (APPEND ${HEADER_FILE} "\tconst char **xpm;\n")
17 FILE (APPEND ${HEADER_FILE} "\tconst char *code;\n")
18 FILE (APPEND ${HEADER_FILE} "};\n")
19 FILE (APPEND ${HEADER_FILE} "\n")
20 FILE (APPEND ${HEADER_FILE} "static struct FlagXPMCode flagXPMCodeVector[] = {\n")
24 FOREACH (FLAG ${FLAGS})
25 STRING (REGEX REPLACE ".xpm" "" CODE ${FLAG})
28 FILE (APPEND ${HEADER_FILE} "\t {${CODE}, \"${CODE}\"}")
31 IF (${CODE} MATCHES "do")
32 FILE (APPEND ${HEADER_FILE} ",\n\t {do_, \"do\"}")
33 ELSE (${CODE} MATCHES "do")
34 FILE (APPEND ${HEADER_FILE} ",\n\t {${CODE}, \"${CODE}\"}")
35 ENDIF (${CODE} MATCHES "do")
37 ENDFOREACH (FLAG ${FLAGS})
39 FILE (APPEND ${HEADER_FILE} "\n")
40 FILE (APPEND ${HEADER_FILE} "};\n")
41 FILE (APPEND ${HEADER_FILE} "\n")
42 FILE (APPEND ${HEADER_FILE} "static const int FLAGS_XPM_SIZE = (sizeof flagXPMCodeVector) / (sizeof flagXPMCodeVector[0]);\n")
43 FILE (APPEND ${HEADER_FILE} "\n")
44 FILE (APPEND ${HEADER_FILE} "} // namespace flags\n")
45 FILE (APPEND ${HEADER_FILE} "#endif // COUNTRY_FLAGS_H\n")