Initially the system is at rest, so total horizontal momentum = 0. After firing:
m(v·cosθ + V) (ball, to the right) = M·V (cannon, to the left), where v is the ball's speed
relative to the cannon, so V = m·v·cosθ / (M + m). Cannon is on a frictionless surface;
the vertical momentum is absorbed by the ground, so only the horizontal component is conserved.