Inconsistency between two formulas for Gravitational Potential Energy that don't yield the same result 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\,$?
 A: There are two problems with the manipulations you've done.
First, the variables in equation (2) are ambiguously named. Equation (2) calculates the potential energy between a single mass $m$ and a mass distribution with total mass $M$. Then the equation should actually read
$$\Omega = - Gm \int \frac{dM}{R}.$$
If we instead write the differential as $dm$, it looks like $m$ is being integrated as well. This results in a meaningless extra factor of $1/2$ when the integration is performed.
Next, the integral over $dM$ shouldn't be naively performed as if $R$ is constant,
$$\int \frac{dM}{R} \neq \frac{M}{R}$$
in general. The issue is that every piece of mass $dM$ has its own radius $R$, so $R$ should be thought of as a function of $M$. If this doesn't make sense, just think about the discrete case,
$$\sum_i \frac{m_i}{R_i}$$
where a radius $R_i$ is associated with every bit of mass $m_i$. 

In your particular case, where we're thinking about two point masses separated by a distance $R$, the quantity $R$ in the integrand really is constant, so we can pull it out for
$$\Omega = - \frac{Gm}{R} \int dM = -\frac{GMm}{R}$$
as expected. For a more general configuration, we would parametrize the masses and radii somehow to get a concrete integral, e.g. we could use the chain rule for
$$\int \frac{dM}{R} = \int \frac{dM}{dR} \frac{dR}{R}$$
where $dM/dR$ tells us the amount of mass in thin spherical shells of radius $R$. I explain how to do this kind of integral a bit more in this answer.
A: These two formulas stand for two different things, the first one
$$U = - \frac{GMm}{r}$$
computes the gravitational potential between two different bodies of mass $M$ and $m$.
The second formula $$\Omega = -\int_{m=0}^M \frac{G \,m \,\mathrm{d}m}{r}$$
gives you the gravitational potential energy that an extended object has, which is the energy difference between the state where all the parts of the object are infinitely far from each other and the state where the object is completely assembled. 
A: To find the potential energy of assembling a sphere of radius $R$ and mass $M$, ie equivalent to the energy released when a mass $M$ starts at infinity as infinitesimal masses and assembles as a sphere of radius $R$, you need to proceed as follows.  
So you have assembled a mass $m = \dfrac 4 3 \pi \rho r^3$ and now add a shell of mass $4\pi r^2 \rho dr$ and thickness $dr$ which moves from infinity to radius $r$ and now change the limits of integration from $m=0$ and $m=M$ to $r = \infty$ and $r=R$ the final radius of the sphere. 
$$\Omega=-\int _\infty^R\dfrac{G\left(\dfrac 4 3 \pi \rho r^3 \right)\left( 4\pi r^2 \rho dr\right)}{r} = - \dfrac {3GM^2}{5R}$$

$-\frac{GM^2}{2r}$ is the potential energy of two spherical masses each of mass $M$ and radius $r$ when their centre to centre separation is $2r$.
A: [During the time I finished writing this answer and then posted it, two other answers had been posted.  I'll leave this here even if it's late to the party.]
Equation (1) is the gravitational potential energy associated with two bodies, a body of mass $m$ at a distance $r$ in the gravitational field (outside) of a body of mass $M$.  These bodies could be point masses.
Equation (2) is the gravitational potential energy associated with one extended body of mass $M$ and radius $r$, e.g., a star.  From the 2nd link you provided:

The integral on the right hand side is the gravitational potential
  energy of the star, i.e., the energy required to assemble the star
  by bringing matter from infinity.

(emphasis mine).
