I have an optimisation problem as follows:

min ||AP - B||^2_F

s.t. P'P = I

where A, B, P are real n*n matrices, || . ||_F is the Frobenius norm, A,B are symmetric positive semi-definite matrices, and P is an unknown orthogonal matrix. By introducing a Langrange multiplier, differentiating and equating to zero, I obtain a result P = (A'A)^-1 B'A, but P isn't orthogonal, and so I've gone wrong somewhere.

If someone could point out how to obtain a solution, and where I have gone wrong, I would be very grateful! Thanks in advance!