The magma wouldn't kill the undead by itself anyway, it'd just light them on fire. If the undead got hit by marksdwarf shots or something enough to make the undead collapse while submerged in magma, the corpse would be incinerated. Just the magma wouldn't be enough though to kill any reanimated undead though.
You could try atom smashers. Wouldn't work on large zombies like forgotten beasts and titans, but it could clear all the goblins and dead migrants.
I modded the raws so that organic materials have a melting point. Zombies do actually die to magma now.
The atomsmasher idea crossed my mind but it would require me to come up with some good way to deal with the beasts and titans, plus a cave dragon and some other really large critters that got zombified. On top of that, it'd be necessary to make a point of access between my fort and the caverns, then (later) the surface. I would probably have to work with artifact furniture and cave-ins to deal with the largest things. I'm not sure how that could work, really. Any ideas would be great.
Obvious solution: Build walkways above for marksdwarves, flood area below with magma, take precautions against flyers.
There is a section of the caves that's now flooded with magma, and I could feasibly carve fortifications for my marksdwarves, but there are two problems. First, I don't have anywhere near enough bolts to deal with two hundred zombies of various kinds. And that's just the caverns. I'd have to atomsmash every corpse as quickly as possible once it was dead to archer fire, and that's just a pain in the ass. I would lose civilians and probably the fort.
Second, the caves can't be flooded entirely due to the above issue: magma will flow off the sides of the map. Otherwise, I'd still be pumping.
What about caving in the whole cavern?
Theoretically, that could be workable. It'd be really messy, though. And I think the corpses will reanimate after being smashed like that. I cannot atomsmash two hundred zombie corpses before some of them get back on their feet and come charging after my dwarves, and if even one forgotten beast or cave dragon reanimates, it's basically game over.