project(lua-scripts)
set(LUA_SCRIPTS_SRC
data.lua
)
set(LUA_SCRIPTS_OUTPUT)
set(LUA_PACKAGES narrator stories json)
foreach(LUA_SCRIPT_FILE ${LUA_SCRIPTS_SRC})
	get_filename_component(FILE_NAME ${LUA_SCRIPT_FILE} NAME_WE)
	set(LUA_SCRIPT_OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME}.lua)
	add_custom_command(OUTPUT ${LUA_SCRIPT_OUTPUT_FILE}
		COMMAND ${CMAKE_COMMAND} -E copy  ${CMAKE_CURRENT_SOURCE_DIR}/${LUA_SCRIPT_FILE} ${LUA_SCRIPT_OUTPUT_FILE}
		DEPENDS ${LUA_SCRIPT_FILE})
	list(APPEND LUA_SCRIPTS_OUTPUT ${LUA_SCRIPT_OUTPUT_FILE})
endforeach()
set(LUA_PACKAGES_OUTPUT)
foreach(LUA_PACKAGE ${LUA_PACKAGES})
    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LUA_PACKAGE}
        COMMAND ${CMAKE_COMMAND} -E copy_directory
            ${CMAKE_CURRENT_SOURCE_DIR}/${LUA_PACKAGE}
            ${CMAKE_CURRENT_BINARY_DIR}/${LUA_PACKAGE}
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${LUA_PACKAGE})
    list(APPEND LUA_PACKAGES_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LUA_PACKAGE})
endforeach()
add_custom_target(stage_lua_scripts ALL DEPENDS ${LUA_SCRIPTS_OUTPUT} ${LUA_PACKAGES_OUTPUT})
