Suprisingly hard actually. You not only need to measure rotation of the base (not trivial but not insanely difficult, gyroscope or compass, or both would do but it's not likely to be accurate enough anyway), but you need to measure where the base as actually moved (much harder since neither GPS, odometry, or inertial tracking is not accurate enough). Of course, if you just want a system that crudely maintains the same direction as the base moves to make things easier for the human that actually does the aiming, then things get much easier because then you dont need targetting accuracy.
The alternative is some vision-like tracking system so it doesnt' matter if the base moves or the target moves. Then it can maintain the target rather than just keeping it in vision.
Of course, the target locking you described is not a "auto-levelling turret" in your thread title which is much easier. Accelerometer or inclinometer and bam.