set(PR_MESH_INDEX 0 CACHE INTERNAL "")

function(PrMeshAsset)
    math(EXPR IDX_TMP "${PR_MESH_INDEX} + 1")
    set(PR_MESH_INDEX ${IDX_TMP} CACHE INTERNAL "")

    cmake_parse_arguments(
        CMESH
        ""
        "NAME;IN;OUT;TARGET"
        ""
        ${ARGN}
    )
    file(MAKE_DIRECTORY ${CMESH_OUT})

    string(MAKE_C_IDENTIFIER "${CMESH_NAME}" MESH_NAME)

    set(TARGET_NAME "CompileMesh-${MESH_NAME}-${PR_MESH_INDEX}")

    add_custom_target(${TARGET_NAME}
        COMMAND AssetUtility -t mesh -i ${CMESH_IN} -o ${CMESH_OUT} --name ${CMESH_NAME}
        COMMENT "Compiling mesh asset: ${CMESH_NAME}"
        VERBATIM
    )
    add_dependencies(${CMESH_TARGET} ${TARGET_NAME})
endfunction()