The problem of waveform optimization design for cognitive radar (CR) in the presence of extended target with unknown target impulse response (TIR) is investigated. On the premise of ensuring the TIR estimation precision, a flexible waveform-constrained optimization design method taking both target detection and range resolution into account is proposed. In this method, both the estimate of TIR and transmitted waveform can be updated according to the environment information fed back by the receiver. Moreover, rather than optimizing waveforms for a single design criterion, the framework can synthesize waveforms that provide a trade-off between competing design criteria. The trade-off is determined by the parameter settings, which can be adjusted according to the requirement of radar performance in each cycle of CR. Simulation results demonstrate that CR with the proposed waveform performs better than a traditional radar system with a fixed waveform and offers more flexibility and practicability.