More cmake fixes

Some cherry picked from my auto-deps branch, along with some new ones. I think a couple of these duplicate some from another pull request for updating modtool's cmake files.