Structural evolution of the kagome superconductors through charge density wave order