I don't use foam for building construction, and when I do use foam for terrain, I generally find that latex-style PVA is sufficient for my purposes. For a more robust solution, with a few toothpicks stuck into both foam pieces (or a hole drilled in the mdf or CD base) to reinforce the bond.
However, several of the video terrain builders I watch on Youtube swear by the hot glue gun. Apparently it makes a strong, quick and easy bond, but the bond sets fast, so there is little margin for adjustments.
I'll be following this thread if somebody comes up with a better option.