Which to install first...closet doors or carpet?
Sliding doors may have a track at the bottom if they are doors riding in bottom side wheels. In this case definitely install the track first and fit up the doors. Carpet tack strip will be installed on either side of the track. Doors can be removed during carpet installation. 

If the sliders are ones with a top hanger track that the doors hang from on rollers then there will be a center guide bracket that keeps the bottom of the doors aligned. With these you generally want to install carpet first as it will be very difficult to access inside the closet to fit the carpet through the opening with two hanging doors in the way. It will also be possible to better gauge the trim length for the doors once the carpet is in place. 

There will be a decision point regarding the sliding door center guide on the floor. The best way to deal with that is to install a small square of plywood right where the guide will be located. This should be about the thickness of the padding. The padding would be cut around this block and carpet laid over the top. The guide will be installed with its screws going through the carpet and into the block below. The purpose of the block is so the guide does not compress the carpet all the way to the floor.