I don't think people understand how dangerous cannon were. A napoleonic cannon ball had way better range than a lightning bolt spell, effective to more than a mile. Anything or anyone you hit becomes shrapnel. You do grazing shots and get rocks and cobbles flying on each bounce. You hit a ship and turn the hull into a wood shotgun blast, ripping up foot-long "splinters" of wood the size of a crosshow bolt and sending them flying. And then there's shot and cannister, a straight up cone of shrapnel or bullets ranging from 1800ft - 2700ft long.
A 20th level caster has, what, a dozen spells of 3rd level and higher? A cannon crew could fire 2-3 shots/minute so 5 minutes of sustained cannon fire outweighs a "fireball!" caster at 20th level. Casters are so not up to the snuff to be Napoleonic cannons. Probably not even 17th century cannons.
The truth is, in a major battle casters are more effectice not doing damage and instead being controllers. Fog to blind gunners & archers, Wall spells & Move Earth to block troops, summons/portals to cause trouble in the rear and countering the enemy casters.
Wars are where warriors, especially archer types, come into their own. They can fight for hours, each one as effective as 6-10 basic troops. A short rest here or there to recover and they are good as new.