Solved
I used this line to see the versions of the packages and know which one I want to change to
dpkg-query -W | grep '~bpo'
after, I purged all I wanted
sudo apt --purge remove libgl1-mesa-dev
sudo apt --purge remove libsdl2-dev
sudo apt --purge remove libgl1-mesa-dri
and more .....
If you use sudo apt remove libgl1-mesa-dev instead of purge, it's not enough. That was my mistake.
After I loaded Retropie-Setup
sudo sh ~/RetroPie-Setup/retropie_setup.sh
and I re-installed all dependency packages
For someone with basic computer skills like me , I had a close call!! 🤣
For CMake, what I did works well, but I don't recommand to play with that without a backup!