project(resources)
set(DIRECTORY_LIST
    main
    shaderlib
    terrain
)
set(TARGET_PATHS)
foreach(DIR_NAME ${DIRECTORY_LIST})
    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DIR_NAME}
        COMMAND ${CMAKE_COMMAND} -E copy_directory
                ${CMAKE_CURRENT_SOURCE_DIR}/${DIR_NAME}
                ${CMAKE_CURRENT_BINARY_DIR}/${DIR_NAME}
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${DIR_NAME})
    list(APPEND TARGET_PATHS ${CMAKE_CURRENT_BINARY_DIR}/${DIR_NAME})
endforeach()
set(COPY_FILES main/flare.png)
set(TARGET_FILES)
foreach(PFILE ${COPY_FILES})
	add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PFILE}
		COMMAND ${CMAKE_COMMAND} -E copy
			${CMAKE_CURRENT_SOURCE_DIR}/${PFILE}
			${CMAKE_CURRENT_BINARY_DIR}/${PFILE}
		DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PFILE}
	)
	list(APPEND TARGET_FILES ${CMAKE_CURRENT_BINARY_DIR}/${PFILE})
endforeach()

#add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/terrain/world_map.png
#                   COMMAND unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/world_map.kra mergedimage.png -d ${CMAKE_CURRENT_BINARY_DIR}/world_map
#                   COMMAND ${CMAKE_COMMAND} -E copy
#                        ${CMAKE_BINARY_DIR}/world_map/mergedimage.png
#                        ${CMAKE_BINARY_DIR}/resources/terrain/world_map.png
#                   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/world_map
#                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/world_map.kra)
#list(APPEND TARGET_PATHS ${CMAKE_CURRENT_BINARY_DIR}/terrain/world_map.png)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/terrain/brushes.png
                   COMMAND unzip -o ${CMAKE_CURRENT_SOURCE_DIR}/brushes.kra mergedimage.png -d ${CMAKE_CURRENT_BINARY_DIR}/brushes
                   COMMAND ${CMAKE_COMMAND} -E copy
                        ${CMAKE_CURRENT_BINARY_DIR}/brushes/mergedimage.png
                        ${CMAKE_CURRENT_BINARY_DIR}/terrain/brushes.png
                   COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/brushes
                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/brushes.kra)
list(APPEND TARGET_PATHS ${CMAKE_CURRENT_BINARY_DIR}/terrain/brushes.png)

add_custom_target(stage_resources ALL DEPENDS ${TARGET_PATHS} ${TARGET_FILES})
