According to this site the general form of the Gravitational Potential Energy of mass $m$ is
$$U=-\frac{GMm}{r}\tag{1}$$ where $G$ is the gravitation constant, $M$ is the mass of the attracting body, and $r$ is the distance between their centre's.
However, I am learning Astrophysics at the moment and in the derivation of the Virial Theorem I came across this alternate definition of the Gravitational Potential Energy $\Omega$
$$\Omega=-\int_{m=0}^M \frac{Gm}{r}\mathrm{d}m\tag{2}$$
So my question is as follows:
If I go ahead and integrate $(2)$ I find that $$\Omega=-\left[\frac{Gm^2}{2r}\right]_{m=0}^{m=M}=-\frac{GM^2}{2r}\ne U$$
But unless I'm mistaken, $\Omega$ must be equal to $U$.
Why are equations $(1)$ and $(2)$ apparently inconsistent due to giving different results?
I tried searching the internet for an explanation but all sites I found give the same result, like this one on page 6.
Therefore, could someone please explain to me why I am finding that $U\ne\Omega\,$?