You can clean the drivetrain until it glistens but after adding a lubricant, and cleaning off the residue, you will still have a coated system after one ride and will have black fingers if you run them over the chain, etc.
The lubricant will move about as the drivetrain is in motion so much of it will wind up outside the pins, etc. of the chain and will be transferred to the rear der. pulleys, chain rings, etc. as you ride. It can't be helped. You can wipe down the drivetrain post ride, just with a cloth, etc. and not add more lube. This will result in less ick after the next ride but it will still be there and you can't get rid of it.
You will just have to live with it as many have done for decades as it is part of the oil based lube process or eliminate it by going to an oil less based lube...immersion waxing, drip wax, etc.
As has been said, WD-40 is not a lubricant it is a 'water dispersant' thus the 'WD'. Use a proper lubricant for moving parts and wipe off the excess.