parentMatrix = the transform of the turret's base (the part that does not rotate)
targetPos = world position of the target
turretPos = world position of the turret
direction = Normalize(targetPos - turretPos);
// Optionally constrain the direction to a plane if you only want the turret piece to rotate on a plane.
direction = parentMatrix.InverseTransformDirection(direction); // convert world direction to local direction
// Generate a quaternion from the direction and local up vector. (my solution is Unity-specific using the LookRotation method)
// Interpolate the turret's orientation towards the quaternion. (my solution is Unity-specific using the RotateTowards method)