Use the same compiler to build the dependencies

Closes issue #2057
Review 1291 by @Tryneus