Hole-doped cuprate superconductors show a ubiquitous tendency towards charge order. Although onset of superconductivity is known to suppress charge order, there has not so far been a decisive demonstration of the reverse process, namely, the effect of charge order on superconductivity. To gain such information, we report here the dependence of the critical temperature $T_{mathrm{c}}$ of YBa$_2$Cu$_3$O$_{6.67}$ on in-plane uniaxial stress up to 2 GPa. At a compression of about 1 GPa along the $a$ axis, 3D-correlated charge density wave (3D CDW) order appears. We find that $T_{mathrm{c}}$ decreases steeply as the applied stress crosses 1 GPa, showing that the appearance of 3D CDW order strongly suppresses superconductivity. Through the elastocaloric effect we resolve the heat capacity anomaly at $T_{mathrm{c}}$, and find that it does not change drastically as the 3D CDW onsets, which shows that the condensation energy of the 3D CDW is considerably less than that of the superconductivity.