Sorry I’ve been swamped so i can’t actually do reaearch and give a full response so I’ll start with a tldr and hopefully come back and give you a real answer later:
earnings are an accounting measure and there’s some flexibility as to whether a given expense is classified as capex, opex, r&d, etc each with different earnings implementations.
In general I prefer cashflow to earnings for that reason.
The next point is cash flow vs free cash flow, fcf factors in capex, etc giving you an accirate idea of how much capital is free to distribute to shareholders (free meaning available).
As one example, look at tsla’s financials. Their gross margins / earnings paint a way better picture than their fcf, because they engage in all the accounting practices that I vaguely referenced above