It's likely that you want the mouse position within the window rather than global location.
Basically, add the window as a parameter to the mouse's getPosition() thus:
sf::Mouse::getPosition(*window);
This position, though, should be converted to the co-ordinate system. This is not really necessary if your view matches the window exactly but there's no reason to not convert just in case.
Assuming you access your window using a pointer called
window, try something like:
const sf::Vector2i mousePosition{ sf::Mouse::getPosition(*window); };
const sf::Vector2f mouseCoord{ window->mapPixelToCoords(mousePosition) };
player.setPosition(mouseCoord);
See the view tutorial, especially the point about co-ordinate conversion:
https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#coordinates-conversions@eXpl0it3r, sorry but I'd already typed this out so posted it anyway