cmake: coalesce EXPAND macros into 3 common macros, and switch to using those; simplifies code and makes maintenance easier.