Build improvements

This fixes non-Xcode builds on OSX, a Clang warning, and cleans up the CMake files a bit. See commit comments for details (is this a bad way to do it...?)
How does it link with `-lpthread` if you don't pass it to the linker driver invocation?