Nematic order has manifested itself in a variety of materials in the cuprate family. We propose an effective field theory of a layered system with incommensurate, intertwined spin-and charge-density wave (SDW and CDW) orders, each of which consists of two components related by C4 rotations. Using a variational method (which is exact in a large N limit), we study the development of nematicity from partially melting those density waves by either increasing temperature or adding quenched disorder. As temperature decreases we first find a transition to a nematic phase, but depending on the range of parameters (e.g. doping concentration) the strongest fluctuations associated with this phase reflect either proximate SDW or CDW order. We also discuss the changes in parameters that can account for the differences in the SDW-CDW interplay between the (214) family and the other hole-doped cuprates.