The problem of adaptive waveform design for target detection in cognitive radar (CR) is investigated. This problem is analyzed in signal-dependent interference, as well as additive channel noise for extended target with unknown target impulse response (TIR). In order to estimate the TIR accurately, the Kalman filter is used in target tracking. In each Kalman filtering iteration, a flexible online waveform spectrum optimization design taking both detection and range resolution into account is modeled in Fourier domain. Unlike existing CR waveform, the proposed waveform can be simultaneously updated according to the environment information fed back by receiver and radar performance demands. Moreover, the influence of waveform spectral phase to radar performance is analyzed. 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 suitability. In addition, waveform spectral phase will not influence tracking, detection, and range resolution performance but will greatly influence waveform forming speed and peak-to-average power ratio.