set(PR_MATERIAL_INDEX 0 CACHE INTERNAL "")

function(PrMaterialAsset)

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

    cmake_parse_arguments(
        CSHDR
        ""
        "NAME;OUT;TARGET"
        "IN"
        ${ARGN}
    )
    file(MAKE_DIRECTORY ${CSHDR_OUT})

    string(MAKE_C_IDENTIFIER "${CSHDR_NAME}" MATERIAL_NAME)

    set(TARGET_NAME "CompileShader-${MATERIAL_NAME}-${PR_MATERIAL_INDEX}")

    set(SHADER_LIB_DIR "${PR_ENGINE_ASSETS_DIR}/ShaderLib")
    set(IN_FILES "")
    foreach(X IN LISTS CSHDR_IN)
        set(IN_FILES ${IN_FILES} "-i" "${X}")
    endforeach()
    add_custom_target(${TARGET_NAME}
        COMMAND AssetUtility -t material ${IN_FILES} -I "${SHADER_LIB_DIR}" -o ${CSHDR_OUT} --name ${CSHDR_NAME}
        COMMENT "Compiling material asset: ${CSHDR_NAME}"
        VERBATIM
    )
    add_dependencies(${CSHDR_TARGET} ${TARGET_NAME})
endfunction()