set(PR_TEXTURE_INDEX 0 CACHE INTERNAL "")

function(PrTextureAsset)

    math(EXPR IDX_TMP "${PR_TEXTURE_INDEX} + 1")
    set(PR_TEXTURE_INDEX ${IDX_TMP} CACHE INTERNAL "")

    cmake_parse_arguments(
        CTEX
        ""
        "NAME;IN;OUT;TARGET"
        ""
        ${ARGN}
    )
    file(MAKE_DIRECTORY ${CTEX_OUT})

    string(MAKE_C_IDENTIFIER "${CTEX_NAME}" TEXTURE_NAME)

    set(TARGET_NAME "CompileTexture-${TEXTURE_NAME}-${PR_TEXTURE_INDEX}")

    add_custom_target(${TARGET_NAME}
        COMMAND AssetUtility -t texture -i ${CTEX_IN} -o ${CTEX_OUT} --name ${CTEX_NAME}
        COMMENT "Compiling texture asset: ${CTEX_NAME}"
        VERBATIM
    )
    add_dependencies(${CTEX_TARGET} ${TARGET_NAME})
endfunction()