function(add_shaders target)
    file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shaders)

    foreach(src IN LISTS ARGN)
        add_custom_command(
            OUTPUT ${src}.spv
            COMMAND glslangValidator -V ${CMAKE_CURRENT_SOURCE_DIR}/${src} -o ${CMAKE_CURRENT_BINARY_DIR}/${src}.spv
            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${src}
        )

        list(APPEND SPV_FILES ${src}.spv)
    endforeach()

    add_custom_target(BuildShaders DEPENDS ${SPV_FILES})
    add_dependencies(${target} BuildShaders)
endfunction()
