“Tilting at windmills” means attacking imaginary enemies. And while most people know it is a reference to Cervantes’ 1604 book Don Quixote, those words are actually not found there. In the popular Spanish novel, Quixote uses his lance to attack a group of windmills which he mistakes for ferocious giants.
Later that century, there is a figurative reference to tilting (or jousting) in a journal written by English poet John Cleveland, “The Quixotes of this Age fight with the Wind-mills of their owne Heads.”
The full form of the phrase isn’t used until towards the end of the 19th century. For example, in The New York Times, April 1870, “They [Western Republicans] have not thus far had sufficient of an organization behind them to make their opposition to the Committee’s bill anything more than tilting at windmills.” Today, I think people use it in an even broader sense to mean a futile effort.
So, even if Cervantes didn’t write the specific words, we have him to thank for this useful phrase.