MACRO(LEMON SPATH VAR)
  IF(UNIX)
    SET(COPY_OR_LINK create_symlink)
  ELSE()
    SET(COPY_OR_LINK copy_if_different)
  ENDIF()
  ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.c ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.h
    COMMAND cmake -E ${COPY_OR_LINK} ${CMAKE_CURRENT_SOURCE_DIR}/${SPATH}.y ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.y
    COMMAND cmake -E chdir ${CMAKE_CURRENT_BINARY_DIR} ${LEMON_EXECUTABLE} T=${LEMON_TEMPLATE} -q ${SPATH}.y
    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${SPATH}.y
    )
  SET(${VAR} ${${VAR}} ${CMAKE_CURRENT_BINARY_DIR}/${SPATH}.c)
ENDMACRO()
