Integrate 3rdparty libraries into build system

Based on #44. Works with MSVC, but needs testing/fixing on other platforms.