MACRO(RAGEL SPATH PARSER_FILE VAR)
  ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.cpp
    COMMAND cmake -E chdir ${CMAKE_CURRENT_SOURCE_DIR} ${RAGEL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${SPATH}.rl -o ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.cpp
    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${SPATH}.rl
    DEPENDS ${PARSER_FILE}
    )
  SET(${VAR} ${${VAR}} ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.cpp)
ENDMACRO()
