The thermodynamic conditions defining the spatial extent of a subsurface region affected by the nucleation and growth of voids in photomechanical spallation of metals is investigated theoretically and in atomistic simulations. A theoretical analysis of cavitation in a surface region of a target melted by laser irradiation suggests a functional form for the temperature dependence of the cavitation threshold. A series of small-scale molecular dynamics simulations performed for Al, Ag, Cr, and Ni has revealed the minimum value of the free energy barrier that results in the onset of cavitation on the timescale of 10s of ps, which is a typical duration of transient tensile stresses produced by the unloading wave generated in the spallation regime. The predictive ability of the theoretical description is verified in large-scale simulations of photomechanical spallation of a Ni target and ablation of an Al target in the phase explosion regime. The temporal and spatial evolution of the free energy barrier for the onset of cavitation under conditions of short pulse laser processing is shown to univocally define the region where the nucleation of voids takes place.