--- /dev/null
+macro (MADMUTT_SOURCES _result _gen)
+ foreach (_current_FILE ${ARGN})
+ get_filename_component(_ext ${_current_FILE} EXT)
+ get_filename_component(_abs ${_current_FILE} ABSOLUTE)
+ get_filename_component(_basename ${_current_FILE} NAME_WE)
+ get_filename_component(_basename ${_current_FILE} NAME_WE)
+ set(_li ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.li)
+ set(_h ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
+ set(_c ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.c)
+ if (_ext STREQUAL ".cpkg")
+ add_custom_command(
+ OUTPUT ${_li}
+ MAIN_DEPENDENCY ${_abs}
+ COMMAND ${madmutt_SOURCE_DIR}/tools/cpkg2c -h ${_abs} > ${_li}
+ COMMENT "Generating ${_li} from ${_abs}"
+ )
+ add_custom_command(
+ OUTPUT ${_c}
+ MAIN_DEPENDENCY ${_abs}
+ COMMAND ${madmutt_SOURCE_DIR}/tools/cpkg2c -c ${_abs} > ${_c}
+ COMMENT "Generating ${_c} from ${_abs}"
+ )
+ list(APPEND ${_result} ${_li} ${_c})
+ list(APPEND ${_gen} ${_li} ${_c})
+ else (_ext STREQUAL ".cpkg")
+ if (_ext STREQUAL ".gperf")
+ add_custom_command(
+ OUTPUT ${_h}
+ MAIN_DEPENDENCY ${_abs}
+ COMMAND sh ${_abs} ${_h} || \(${RM} ${_h}; exit 1\)
+ COMMENT "Generating ${_h} from ${_abs}"
+ )
+ add_custom_command(
+ OUTPUT ${_c}
+ MAIN_DEPENDENCY ${_abs}
+ COMMAND sh ${_abs} ${_c} || \(${RM} ${_c}; exit 1\)
+ COMMENT "Generating ${_c} from ${_abs}"
+ )
+ list(APPEND ${_result} ${_h} ${_c})
+ list(APPEND ${_gen} ${_h} ${_c})
+ else (_ext STREQUAL ".gperf")
+ list(APPEND ${_result} ${_current_FILE})
+ endif (_ext STREQUAL ".gperf")
+ endif (_ext STREQUAL ".cpkg")
+ endforeach(_current_FILE)
+endmacro (MADMUTT_SOURCES)
+