Measure the width from one wall to the other and the height from the floor to the ceiling.
Additionally, be sure to measure any potential obstructions like windows, outlets, switches, plumbing, access panels, attic access doors, vents, light fixtures, or anything else that could interfere with the closet installation.